diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2009-11-02 08:26:03 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2009-11-02 08:26:03 +0000 |
| commit | 5dfed1b24a0a68aab25c10ca9e69072188baa3c9 (patch) | |
| tree | deb77ef5901dd9ea8415054348487520a7ff6226 /tests/regressiontests/dateformat | |
| parent | be89c9ababd85ec25606b39b408a2ab7ee6da357 (diff) | |
Fixed #12127 -- Corrected teardown of dateformat tests. Thanks to apollo13 for the report, and Karen Tracey for the debugging help.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@11705 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/dateformat')
| -rw-r--r-- | tests/regressiontests/dateformat/tests.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/regressiontests/dateformat/tests.py b/tests/regressiontests/dateformat/tests.py index 3a19d26e19..bbde45b903 100644 --- a/tests/regressiontests/dateformat/tests.py +++ b/tests/regressiontests/dateformat/tests.py @@ -9,12 +9,24 @@ class DateFormatTests(TestCase): os.environ['TZ'] = 'Europe/Copenhagen' translation.activate('en-us') + try: + # Check if a timezone has been set + time.tzset() + self.tz_tests = True + except AttributeError: + # No timezone available. Don't run the tests that require a TZ + self.tz_tests = False + def tearDown(self): if self.old_TZ is None: del os.environ['TZ'] else: os.environ['TZ'] = self.old_TZ + # Cleanup - force re-evaluation of TZ environment variable. + if self.tz_tests: + time.tzset() + def test_empty_format(self): my_birthday = datetime.datetime(1979, 7, 8, 22, 00) @@ -68,10 +80,7 @@ class DateFormatTests(TestCase): summertime = datetime.datetime(2005, 10, 30, 1, 00) wintertime = datetime.datetime(2005, 10, 30, 4, 00) - try: - # Check if a timezone has been set - time.tzset() - + if self.tz_tests: self.assertEquals(dateformat.format(my_birthday, 'O'), u'+0100') self.assertEquals(dateformat.format(my_birthday, 'r'), u'Sun, 8 Jul 1979 22:00:00 +0100') self.assertEquals(dateformat.format(my_birthday, 'T'), u'CET') @@ -81,6 +90,3 @@ class DateFormatTests(TestCase): self.assertEquals(dateformat.format(summertime, 'O'), u'+0200') self.assertEquals(dateformat.format(wintertime, 'I'), u'0') self.assertEquals(dateformat.format(wintertime, 'O'), u'+0100') - except AttributeError: - # No timezone available. Don't run the tests - pass |
