mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Converted test fixtures to setUpTestData methods
This commit is contained in:
parent
d6969abf23
commit
39a7eed1bb
69 changed files with 2077 additions and 2819 deletions
|
@ -1,3 +1,4 @@
|
|||
import datetime
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
|
@ -12,6 +13,19 @@ from django.test import TestCase, modify_settings, override_settings
|
|||
from .models import Company, Person
|
||||
|
||||
|
||||
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)
|
||||
)
|
||||
|
||||
|
||||
@override_settings(
|
||||
PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
|
||||
ROOT_URLCONF='admin_docs.urls')
|
||||
|
@ -39,8 +53,7 @@ class MiscTests(AdminDocsTestCase):
|
|||
|
||||
|
||||
@unittest.skipUnless(utils.docutils_is_available, "no docutils installed.")
|
||||
class AdminDocViewTests(AdminDocsTestCase):
|
||||
fixtures = ['data.xml']
|
||||
class AdminDocViewTests(TestDataMixin, AdminDocsTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(username='super', password='secret')
|
||||
|
@ -124,8 +137,7 @@ class AdminDocViewTests(AdminDocsTestCase):
|
|||
utils.docutils_is_available = True
|
||||
|
||||
|
||||
class XViewMiddlewareTest(AdminDocsTestCase):
|
||||
fixtures = ['data.xml']
|
||||
class XViewMiddlewareTest(TestDataMixin, AdminDocsTestCase):
|
||||
|
||||
def test_xview_func(self):
|
||||
user = User.objects.get(username='super')
|
||||
|
@ -201,13 +213,11 @@ class DefaultRoleTest(AdminDocsTestCase):
|
|||
|
||||
|
||||
@unittest.skipUnless(utils.docutils_is_available, "no docutils installed.")
|
||||
class TestModelDetailView(AdminDocsTestCase):
|
||||
class TestModelDetailView(TestDataMixin, AdminDocsTestCase):
|
||||
"""
|
||||
Tests that various details render correctly
|
||||
"""
|
||||
|
||||
fixtures = ['data.xml']
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(username='super', password='secret')
|
||||
self.response = self.client.get(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue