Utils Test

inyoka.testing

Various utilities and helpers that improve our unittest experience.

copyright:
  1. 2007-2025 by the Inyoka Team, see AUTHORS for more details.

license:

BSD, see LICENSE for more details.

class inyoka.utils.test.AntiSpamTestCaseMixin
make_mark_ham()
make_mark_spam()
make_spam()
make_valid_key()
class inyoka.utils.test.InyokaClient(enforce_csrf_checks=False, host=None, **defaults)

In order to change the requesting host, use:

client.defaults['HTTP_HOST'] = 'url.example.com'
login(**credentials)

Try to authenticate a user with username and password.

Parameters:
  • username (str) – The username of the User to log in

  • password (str) – The password of the user to login

Raise:
User.DoesNotExist

If the user with username does not exist

UserBanned

If the found user is banned

Returns:

True in case the described user can be logged in, and is active, False otherwise.

class inyoka.utils.test.TestCase(methodName='runTest')

Default TestCase for all Inyoka tests.

Deletes the content cache after each run.

_classSetupFailed = False
_class_cleanups = []
_msg_not_null_constraint(relation: str, column: str) str

If you want to check the message of an IntegrityError with self.assertRaisesMessage, the messages differ between database backends. This method helps to act as an abstraction layer.

Example for the parameters: In the app ikhaya, the model Article and the field text:
  • the relation is ikhaya_article.text and

  • the column text

_msg_unique_constraint(constraint_name: str) str

If you want to check the message of an IntegrityError with self.assertRaisesMessage, the messages differ between database backends. This method helps to act as an abstraction layer.

_post_teardown()

Flush cache

assertXMLEqual(xml1, xml2, msg=None)

Prettify comparison of two XML strings

inyoka.utils.test.profile_memory(func)