Base Test Case
User object that was logged into the site using
Create a random string of the given length. The string will consist of only ASCII letters and digits.
createUser(userName=None, password=None, *, email=None)
createAdminUser(userName=None, password=None, *, email=None)
createSuperUser(userName=None, password=None, *, email=None)
Create a new user in the database. Any arguments not given will be generated randomly. The
createAdminUser gets the
is_staff flag while
CreateSuperUser gets both the
is_superuser flags. Users are also given
randomly generated first and last names.
logInAs(user=None, *, password=None) -> User
Log the specified user into the site. If no user is given then one will be created.
password keyword argument only needs to be supplied if the user was not
created using one of the
createUser methods or if the code needs to give a purposefully incorrect
This method returns the logged in user upon success.
For unit tests this method will log in using the Django test client (i.e.
For browser tests this method will direct the browser to the site's login page and log in using the form found there. See Browser Test Case for details about how to describe the login page for the site.
Cause the currently logged in user to log out.
For unit tests this method will log out using the Django test client (i.e.
For browser tests this method will direct the browser trigger a log out operation. See Browser Test Case for details about how to describe the log out process for the site.
Cause the given session object to expire immediately. When using
session argument can be
omitted. In this case the test client's session (i.e.
self.client.session) will be expired.
Asserts that the given number of emails was sent using Django's mail module.
Returns, as a list, all emails that were sent with the given subject.
Returns, as a list, all emails that were sent to the given email address.