2014-05-30 14:55:04 +00:00
|
|
|
from django.contrib.auth.models import User
|
2014-02-17 10:52:52 +00:00
|
|
|
|
2014-05-10 12:21:21 +00:00
|
|
|
# We need to make sure that we're using the same unittest library that Django uses internally
|
|
|
|
|
# Otherwise, we get issues with the "SkipTest" and "ExpectedFailure" exceptions being recognised as errors
|
|
|
|
|
try:
|
|
|
|
|
# Firstly, try to import unittest from Django
|
|
|
|
|
from django.utils import unittest
|
|
|
|
|
except ImportError:
|
|
|
|
|
# Django doesn't include unittest
|
|
|
|
|
# We must be running on Django 1.7+ which doesn't support Python 2.6 so
|
|
|
|
|
# the standard unittest library should be unittest2
|
|
|
|
|
import unittest
|
|
|
|
|
|
2014-02-17 10:52:52 +00:00
|
|
|
|
2014-06-02 12:59:06 +00:00
|
|
|
class WagtailTestUtils(object):
|
2014-06-02 12:40:34 +00:00
|
|
|
def login(self):
|
2014-06-02 15:07:31 +00:00
|
|
|
# Create a user
|
|
|
|
|
user = User.objects.create_superuser(username='test', email='test@email.com', password='password')
|
|
|
|
|
|
|
|
|
|
# Login
|
|
|
|
|
self.client.login(username='test', password='password')
|
|
|
|
|
|
|
|
|
|
return user
|