From 1a1e14786aa35b4d80b46be747b5128800cf0f97 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sun, 8 Sep 2013 19:38:12 +0200 Subject: [PATCH] Hardened the test introduced in ded11aa6. Refs #18766. Inputs acceptable to time.mktime are platform-dependent. --- tests/utils_tests/test_timezone.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/utils_tests/test_timezone.py b/tests/utils_tests/test_timezone.py index d0fbc54840..e6c08b05ca 100644 --- a/tests/utils_tests/test_timezone.py +++ b/tests/utils_tests/test_timezone.py @@ -24,8 +24,12 @@ class TimezoneTests(unittest.TestCase): def test_localtime_out_of_range(self): local_tz = timezone.LocalTimezone() long_ago = datetime.datetime(1900, 1, 1, tzinfo=timezone.utc) - with six.assertRaisesRegex(self, OverflowError, "install pytz"): + try: timezone.localtime(long_ago, local_tz) + except OverflowError as exc: + self.assertIn("install pytz", exc.args[0]) + else: + raise unittest.SkipTest("Failed to trigger an OverflowError") def test_now(self): with override_settings(USE_TZ=True):