oioioi.base.tests

Submodules

Package Contents

Classes

_AssertNumQueriesLessThanContext

Context manager that captures queries executed by the specified connection.

TestCase

Similar to TransactionTestCase, but use transaction.atomic() to achieve

IgnorePasswordAuthBackend

An authentication backend which accepts any password for an existing

FakeTimeMiddleware

TestsUtilsMixin

Functions

fake_time(timestamp)

A context manager which causes all requests having the specified

fake_timezone_now(timestamp)

get_url(url_or_viewname, qs, *args, **kwargs)

check_not_accessible(testcase, url_or_viewname[, qs])

check_is_accessible(testcase, url_or_viewname[, qs])

check_ajax_not_accessible(testcase, url_or_viewname, ...)

needs_linux(fn)

class oioioi.base.tests._AssertNumQueriesLessThanContext(test_case, num, connection)[source]

Bases: django.test.utils.CaptureQueriesContext

Context manager that captures queries executed by the specified connection.

__exit__(exc_type, exc_value, traceback)[source]
class oioioi.base.tests.TestCase(methodName='runTest')[source]

Bases: django.test.TestCase

Similar to TransactionTestCase, but use transaction.atomic() to achieve test isolation.

In most situations, TestCase should be preferred to TransactionTestCase as it allows faster execution. However, there are some situations where using TransactionTestCase might be necessary (e.g. testing some transactional behavior).

On database backends with no transaction support, TestCase behaves as TransactionTestCase.

assertNumQueriesLessThan(num, *args, **kwargs)[source]
assertRegex(text, regex, msg=None)[source]

Fail the test unless the text matches the regular expression.

assertNotRegex(text, regex, msg=None)[source]

Fail the test if the text matches the regular expression.

class oioioi.base.tests.IgnorePasswordAuthBackend[source]

Bases: object

An authentication backend which accepts any password for an existing user.

It’s configured in test_settings.py and available for all tests.

supports_authentication = True[source]
description[source]
authenticate(request, username=None, password=None, **kwargs)[source]
get_user(user_id)[source]
class oioioi.base.tests.FakeTimeMiddleware(get_response)[source]

Bases: object

_fake_timestamp[source]
__call__(request)[source]
_process_request(request)[source]
oioioi.base.tests.fake_time(timestamp)[source]

A context manager which causes all requests having the specified timestamp, regardless of the real wall clock time.

oioioi.base.tests.fake_timezone_now(timestamp)[source]
oioioi.base.tests.get_url(url_or_viewname, qs, *args, **kwargs)[source]
oioioi.base.tests.check_not_accessible(testcase, url_or_viewname, qs=None, *args, **kwargs)[source]
oioioi.base.tests.check_is_accessible(testcase, url_or_viewname, qs=None, *args, **kwargs)[source]
oioioi.base.tests.check_ajax_not_accessible(testcase, url_or_viewname, *args, **kwargs)[source]
class oioioi.base.tests.TestsUtilsMixin[source]

Bases: object

assertAllIn(elems, container, msg=None)[source]

Checks that container contains all elems.

assertNoneIn(elems, container, msg=None)[source]

Checks that container doesn’t contain any of elems.

oioioi.base.tests.needs_linux(fn)[source]