diff --git a/tests/regressiontests/utils/dateformat.py b/tests/regressiontests/utils/dateformat.py index 6afbcd61ec..2ff3441486 100644 --- a/tests/regressiontests/utils/dateformat.py +++ b/tests/regressiontests/utils/dateformat.py @@ -6,11 +6,14 @@ from django.utils.tzinfo import FixedOffset, LocalTimezone class DateFormatTests(TestCase): def setUp(self): - self.old_TZ = os.environ['TZ'] + self.old_TZ = os.environ.get('TZ') os.environ['TZ'] = 'Europe/Copenhagen' def tearDown(self): - os.environ['TZ'] = self.old_TZ + if self.old_TZ is None: + del os.environ['TZ'] + else: + os.environ['TZ'] = self.old_TZ def test_date(self): d = date(2009, 5, 16)