mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #12991 -- Added unittest2 support. Thanks to PaulM for the draft patch, and to Luke, Karen, Justin, Alex, Łukasz Rekucki, and Chuck Harmston for their help testing and reviewing the final patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14139 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -12,13 +12,14 @@ from django.contrib.admin.sites import LOGIN_FORM_KEY
|
||||
from django.contrib.admin.util import quote
|
||||
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
|
||||
from django.forms.util import ErrorList
|
||||
import django.template.context
|
||||
from django.test import TestCase
|
||||
from django.utils import formats
|
||||
from django.utils.cache import get_max_age
|
||||
from django.utils.encoding import iri_to_uri
|
||||
from django.utils.html import escape
|
||||
from django.utils.translation import get_date_formats, activate, deactivate
|
||||
import django.template.context
|
||||
from django.utils import unittest
|
||||
|
||||
# local test models
|
||||
from models import Article, BarAccount, CustomArticle, EmptyModel, \
|
||||
@@ -2210,51 +2211,52 @@ class UserAdminTest(TestCase):
|
||||
self.assertNotEquals(new_user.password, UNUSABLE_PASSWORD)
|
||||
|
||||
try:
|
||||
# If docutils isn't installed, skip the AdminDocs tests.
|
||||
import docutils
|
||||
|
||||
class AdminDocsTest(TestCase):
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(username='super', password='secret')
|
||||
|
||||
def tearDown(self):
|
||||
self.client.logout()
|
||||
|
||||
def test_tags(self):
|
||||
response = self.client.get('/test_admin/admin/doc/tags/')
|
||||
|
||||
# The builtin tag group exists
|
||||
self.assertContains(response, "<h2>Built-in tags</h2>", count=2)
|
||||
|
||||
# A builtin tag exists in both the index and detail
|
||||
self.assertContains(response, '<h3 id="built_in-autoescape">autoescape</h3>')
|
||||
self.assertContains(response, '<li><a href="#built_in-autoescape">autoescape</a></li>')
|
||||
|
||||
# An app tag exists in both the index and detail
|
||||
self.assertContains(response, '<h3 id="flatpages-get_flatpages">get_flatpages</h3>')
|
||||
self.assertContains(response, '<li><a href="#flatpages-get_flatpages">get_flatpages</a></li>')
|
||||
|
||||
# The admin list tag group exists
|
||||
self.assertContains(response, "<h2>admin_list</h2>", count=2)
|
||||
|
||||
# An admin list tag exists in both the index and detail
|
||||
self.assertContains(response, '<h3 id="admin_list-admin_actions">admin_actions</h3>')
|
||||
self.assertContains(response, '<li><a href="#admin_list-admin_actions">admin_actions</a></li>')
|
||||
|
||||
def test_filters(self):
|
||||
response = self.client.get('/test_admin/admin/doc/filters/')
|
||||
|
||||
# The builtin filter group exists
|
||||
self.assertContains(response, "<h2>Built-in filters</h2>", count=2)
|
||||
|
||||
# A builtin filter exists in both the index and detail
|
||||
self.assertContains(response, '<h3 id="built_in-add">add</h3>')
|
||||
self.assertContains(response, '<li><a href="#built_in-add">add</a></li>')
|
||||
|
||||
except ImportError:
|
||||
pass
|
||||
docutils = None
|
||||
|
||||
#@unittest.skipUnless(docutils, "no docutils installed.")
|
||||
class AdminDocsTest(TestCase):
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
||||
def setUp(self):
|
||||
self.client.login(username='super', password='secret')
|
||||
|
||||
def tearDown(self):
|
||||
self.client.logout()
|
||||
|
||||
def test_tags(self):
|
||||
response = self.client.get('/test_admin/admin/doc/tags/')
|
||||
|
||||
# The builtin tag group exists
|
||||
self.assertContains(response, "<h2>Built-in tags</h2>", count=2)
|
||||
|
||||
# A builtin tag exists in both the index and detail
|
||||
self.assertContains(response, '<h3 id="built_in-autoescape">autoescape</h3>')
|
||||
self.assertContains(response, '<li><a href="#built_in-autoescape">autoescape</a></li>')
|
||||
|
||||
# An app tag exists in both the index and detail
|
||||
self.assertContains(response, '<h3 id="flatpages-get_flatpages">get_flatpages</h3>')
|
||||
self.assertContains(response, '<li><a href="#flatpages-get_flatpages">get_flatpages</a></li>')
|
||||
|
||||
# The admin list tag group exists
|
||||
self.assertContains(response, "<h2>admin_list</h2>", count=2)
|
||||
|
||||
# An admin list tag exists in both the index and detail
|
||||
self.assertContains(response, '<h3 id="admin_list-admin_actions">admin_actions</h3>')
|
||||
self.assertContains(response, '<li><a href="#admin_list-admin_actions">admin_actions</a></li>')
|
||||
|
||||
def test_filters(self):
|
||||
response = self.client.get('/test_admin/admin/doc/filters/')
|
||||
|
||||
# The builtin filter group exists
|
||||
self.assertContains(response, "<h2>Built-in filters</h2>", count=2)
|
||||
|
||||
# A builtin filter exists in both the index and detail
|
||||
self.assertContains(response, '<h3 id="built_in-add">add</h3>')
|
||||
self.assertContains(response, '<li><a href="#built_in-add">add</a></li>')
|
||||
|
||||
AdminDocsTest = unittest.skipUnless(docutils, "no docutils installed.")(AdminDocsTest)
|
||||
|
||||
class ValidXHTMLTests(TestCase):
|
||||
fixtures = ['admin-views-users.xml']
|
||||
|
||||
Reference in New Issue
Block a user