Utilities

class django_functest.AdminLoginMixin[source]

This provides helpers for logging into the admin interface using the standard login page. It assumes logging in with username and password.

This works with both FuncWebTestMixin and FuncSeleniumMixin.

do_login(username=None, password=None, shortcut=True)[source]

Do an admin login for the provided username and password. However, it will actually do a shortcut by default, unless shortcut=False is passed, using the shortcut_login().

do_logout(shortcut=True)[source]

Do a log out for the current user, using shortcut_logout() if shortcut=True (the default), or using the admin logout page if shortcut=False

class django_functest.ShortcutLoginMixin[source]

This provides a method for doing a login without actually doing HTTP-level work, as far as possible.

This works with both FuncWebTestMixin and FuncSeleniumMixin. These methods do not simulate exactly what happens when a user logs in and out with real HTTP requests — they only do enough to get you to “logged in user”, or “logged out user” state. In particular, other side effects on the session that normally happen (such as session key rotation, or anything that responds to the user_logged_in signal etc.) will not be done.

shortcut_login(**credentials)[source]

Pass credentials (typically username and password), as accepted by django.contrib.auth.authenticate, and if they are valid, you will get a session where the user is logged in. Otherwise an exception is raised.

Manipulates the session and cookies directly.

shortcut_logout()[source]

Logs out the user from the current session

Manipulates the session and cookies directly.

class django_functest.MultiThreadedLiveServerMixin[source]

Add this as a mixin to any test class (or test class base) to enable a multi-threaded live server.

This makes it possible to use some browsers (e.g. Chrome) in combination with test methods like new_browser_session().

Note that there are some limitations:

  • You cannot use this with an in-memory SQLite test database. You will need to set a NAME parameter for the test database to force it to be a non-in-memory database.

On Django 2.0 and greater, this is class does nothing since the Django 2.0 LiveServerTestCase already has this behaviour builtin.