Cleaned up the tests from r15451 to avoid the need to retrieve a URL twice.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15453 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee 2011-02-08 12:20:18 +00:00
parent 74ffca17e2
commit 4e7c2ba1d7
1 changed files with 11 additions and 12 deletions

View File

@ -441,7 +441,7 @@ class AdminJavaScriptTest(AdminViewBasicTest):
response, response,
'<script type="text/javascript">document.getElementById("id_name").focus();</script>' '<script type="text/javascript">document.getElementById("id_name").focus();</script>'
) )
def testMultiWidgetFirsFieldFocus(self): def testMultiWidgetFirsFieldFocus(self):
""" """
JavaScript-assisted auto-focus should work if a model/ModelAdmin setup JavaScript-assisted auto-focus should work if a model/ModelAdmin setup
@ -2619,11 +2619,10 @@ class DateHierarchyTests(TestCase):
settings.USE_THOUSAND_SEPARATOR = self.old_USE_THOUSAND_SEPARATOR settings.USE_THOUSAND_SEPARATOR = self.old_USE_THOUSAND_SEPARATOR
settings.USE_L10N = self.old_USE_L10N settings.USE_L10N = self.old_USE_L10N
def assert_non_localized_year(self, url, year): def assert_non_localized_year(self, response, year):
"""Ensure that the year is not localized with """Ensure that the year is not localized with
USE_THOUSAND_SEPARATOR. Refs #15234. USE_THOUSAND_SEPARATOR. Refs #15234.
""" """
response = self.client.get(url)
self.assertNotContains(response, formats.number_format(year)) self.assertNotContains(response, formats.number_format(year))
def assert_contains_year_link(self, response, date): def assert_contains_year_link(self, response, date):
@ -2659,7 +2658,7 @@ class DateHierarchyTests(TestCase):
url = reverse('admin:admin_views_podcast_changelist') url = reverse('admin:admin_views_podcast_changelist')
response = self.client.get(url) response = self.client.get(url)
self.assert_contains_day_link(response, DATE) self.assert_contains_day_link(response, DATE)
self.assert_non_localized_year(url, 2000) self.assert_non_localized_year(response, 2000)
def test_within_month(self): def test_within_month(self):
""" """
@ -2674,7 +2673,7 @@ class DateHierarchyTests(TestCase):
response = self.client.get(url) response = self.client.get(url)
for date in DATES: for date in DATES:
self.assert_contains_day_link(response, date) self.assert_contains_day_link(response, date)
self.assert_non_localized_year(url, 2000) self.assert_non_localized_year(response, 2000)
def test_within_year(self): def test_within_year(self):
""" """
@ -2691,7 +2690,7 @@ class DateHierarchyTests(TestCase):
self.assertNotContains(response, 'release_date__day=') self.assertNotContains(response, 'release_date__day=')
for date in DATES: for date in DATES:
self.assert_contains_month_link(response, date) self.assert_contains_month_link(response, date)
self.assert_non_localized_year(url, 2000) self.assert_non_localized_year(response, 2000)
def test_multiple_years(self): def test_multiple_years(self):
""" """
@ -2717,15 +2716,15 @@ class DateHierarchyTests(TestCase):
date.year) date.year)
response = self.client.get(url) response = self.client.get(url)
self.assert_contains_month_link(response, date) self.assert_contains_month_link(response, date)
self.assert_non_localized_year(url, 2000) self.assert_non_localized_year(response, 2000)
self.assert_non_localized_year(url, 2003) self.assert_non_localized_year(response, 2003)
self.assert_non_localized_year(url, 2005) self.assert_non_localized_year(response, 2005)
url = '%s?release_date__year=%d&release_date__month=%d' % ( url = '%s?release_date__year=%d&release_date__month=%d' % (
reverse('admin:admin_views_podcast_changelist'), reverse('admin:admin_views_podcast_changelist'),
date.year, date.month) date.year, date.month)
response = self.client.get(url) response = self.client.get(url)
self.assert_contains_day_link(response, date) self.assert_contains_day_link(response, date)
self.assert_non_localized_year(url, 2000) self.assert_non_localized_year(response, 2000)
self.assert_non_localized_year(url, 2003) self.assert_non_localized_year(response, 2003)
self.assert_non_localized_year(url, 2005) self.assert_non_localized_year(response, 2005)