diff options
author | Mads Jensen <mje@inducks.org> | 2017-05-28 21:37:21 +0200 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-07-29 19:07:23 -0400 |
commit | a51c4de1945be2225f20fad794cfb52d8f1f9236 (patch) | |
tree | 36386b70a27cf027a8a491de319c3e59e0d3d0cd /tests/timezones | |
parent | 38988f289f7f5708f5ea85de2d5dfe0d86b23106 (diff) | |
download | django-a51c4de1945be2225f20fad794cfb52d8f1f9236.tar.gz |
Used assertRaisesMessage() to test Django's error messages.
Diffstat (limited to 'tests/timezones')
-rw-r--r-- | tests/timezones/tests.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py index 7c83ffbc47..926b8de704 100644 --- a/tests/timezones/tests.py +++ b/tests/timezones/tests.py @@ -123,7 +123,8 @@ class LegacyDatabaseTests(TestCase): @skipIfDBFeature('supports_timezones') def test_aware_datetime_unsupported(self): dt = datetime.datetime(2011, 9, 1, 13, 20, 30, tzinfo=EAT) - with self.assertRaises(ValueError): + msg = 'backend does not support timezone-aware datetimes when USE_TZ is False.' + with self.assertRaisesMessage(ValueError, msg): Event.objects.create(dt=dt) def test_auto_now_and_auto_now_add(self): @@ -647,7 +648,11 @@ class UnsupportedTimeZoneDatabaseTests(TestCase): connections.databases['tz']['TIME_ZONE'] = 'Asia/Bangkok' tz_conn = connections['tz'] try: - with self.assertRaises(ImproperlyConfigured): + msg = ( + "Connection 'tz' cannot set TIME_ZONE because its engine " + "handles time zones conversions natively." + ) + with self.assertRaisesMessage(ImproperlyConfigured, msg): tz_conn.cursor() finally: connections['tz'].close() # in case the test fails @@ -1033,7 +1038,8 @@ class TemplateTests(SimpleTestCase): self.assertEqual(tpl.render(Context()), "Europe/Paris") def test_get_current_timezone_templatetag_invalid_argument(self): - with self.assertRaises(TemplateSyntaxError): + msg = "'get_current_timezone' requires 'as variable' (got ['get_current_timezone'])" + with self.assertRaisesMessage(TemplateSyntaxError, msg): Template("{% load tz %}{% get_current_timezone %}").render() @skipIf(sys.platform.startswith('win'), "Windows uses non-standard time zone names") |