summaryrefslogtreecommitdiff
path: root/tests/generic_inline_admin
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2015-02-23 11:53:57 +1100
committerJosh Smeaton <josh.smeaton@gmail.com>2015-03-05 10:10:32 +1100
commit39a7eed1bbf12020a077e4bec3d82e08f171a021 (patch)
tree225be14a94d57517d9de646569498eb45d0a4352 /tests/generic_inline_admin
parentd6969abf239d52f6dfed7384c6ceb7df7e618342 (diff)
downloaddjango-39a7eed1bbf12020a077e4bec3d82e08f171a021.tar.gz
Converted test fixtures to setUpTestData methods
Diffstat (limited to 'tests/generic_inline_admin')
-rw-r--r--tests/generic_inline_admin/fixtures/users.xml17
-rw-r--r--tests/generic_inline_admin/tests.py24
2 files changed, 18 insertions, 23 deletions
diff --git a/tests/generic_inline_admin/fixtures/users.xml b/tests/generic_inline_admin/fixtures/users.xml
deleted file mode 100644
index 6cf441f01e..0000000000
--- a/tests/generic_inline_admin/fixtures/users.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<django-objects version="1.0">
- <object pk="100" model="auth.user">
- <field type="CharField" name="username">super</field>
- <field type="CharField" name="first_name">Super</field>
- <field type="CharField" name="last_name">User</field>
- <field type="CharField" name="email">super@example.com</field>
- <field type="CharField" name="password">sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158</field>
- <field type="BooleanField" name="is_staff">True</field>
- <field type="BooleanField" name="is_active">True</field>
- <field type="BooleanField" name="is_superuser">True</field>
- <field type="DateTimeField" name="last_login">2007-05-30 13:20:10</field>
- <field type="DateTimeField" name="date_joined">2007-05-30 13:20:10</field>
- <field to="auth.group" name="groups" rel="ManyToManyRel"></field>
- <field to="auth.permission" name="user_permissions" rel="ManyToManyRel"></field>
- </object>
-</django-objects> \ No newline at end of file
diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
index 91883e1170..834cd80c5d 100644
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+import datetime
+
from django.contrib import admin
from django.contrib.admin.sites import AdminSite
from django.contrib.auth.models import User
@@ -15,6 +17,19 @@ from .admin import MediaInline, MediaPermanentInline, site as admin_site
from .models import Category, Episode, EpisodePermanent, Media
+class TestDataMixin(object):
+
+ @classmethod
+ def setUpTestData(cls):
+ # password = "secret"
+ User.objects.create(
+ pk=100, username='super', first_name='Super', last_name='User', email='super@example.com',
+ password='sha1$995a3$6011485ea3834267d719b4c801409b8b1ddd0158', is_active=True, is_superuser=True,
+ is_staff=True, last_login=datetime.datetime(2007, 5, 30, 13, 20, 10),
+ date_joined=datetime.datetime(2007, 5, 30, 13, 20, 10)
+ )
+
+
# Set DEBUG to True to ensure {% include %} will raise exceptions.
# That is how inlines are rendered and #9498 will bubble up if it is an issue.
@override_settings(
@@ -22,8 +37,7 @@ from .models import Category, Episode, EpisodePermanent, Media
PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF="generic_inline_admin.urls",
)
-class GenericAdminViewTest(TestCase):
- fixtures = ['users.xml']
+class GenericAdminViewTest(TestDataMixin, TestCase):
def setUp(self):
self.client.login(username='super', password='secret')
@@ -129,8 +143,7 @@ class GenericAdminViewTest(TestCase):
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF="generic_inline_admin.urls")
-class GenericInlineAdminParametersTest(TestCase):
- fixtures = ['users.xml']
+class GenericInlineAdminParametersTest(TestDataMixin, TestCase):
def setUp(self):
self.client.login(username='super', password='secret')
@@ -276,8 +289,7 @@ class GenericInlineAdminParametersTest(TestCase):
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
ROOT_URLCONF="generic_inline_admin.urls")
-class GenericInlineAdminWithUniqueTogetherTest(TestCase):
- fixtures = ['users.xml']
+class GenericInlineAdminWithUniqueTogetherTest(TestDataMixin, TestCase):
def setUp(self):
self.client.login(username='super', password='secret')