diff options
author | Jan Willhaus <mail@janwillhaus.de> | 2019-11-02 22:55:07 +0100 |
---|---|---|
committer | Jan Willhaus <mail@janwillhaus.de> | 2019-11-02 23:00:17 +0100 |
commit | a4bc7c7854a95c899746d32866e5c82665b699b9 (patch) | |
tree | 4fabb9001584ef5e0ca3a8abfd0c4cd4fa7da7cf | |
parent | 46e47257becf8682bebcc97efbc1b24d0b2db108 (diff) | |
download | warlock-a4bc7c7854a95c899746d32866e5c82665b699b9.tar.gz |
Use Python 2.7-friendly version of assessing warnings
-rw-r--r-- | tests/test_core.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/test_core.py b/tests/test_core.py index 4d39303..bc9434a 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -16,6 +16,7 @@ import copy import json import os import unittest +import warnings import six @@ -187,14 +188,20 @@ class TestCore(unittest.TestCase): def test_changes(self): Country = warlock.model_factory(fixture) sweden = Country(name="Sweden", population=9379116) - with self.assertWarns(DeprecationWarning): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") self.assertEqual(sweden.changes, {}) + assert w[0].category == DeprecationWarning sweden["name"] = "Finland" - with self.assertWarns(DeprecationWarning): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") self.assertEqual(sweden.changes, {"name": "Finland"}) + assert w[0].category == DeprecationWarning sweden["name"] = "Norway" - with self.assertWarns(DeprecationWarning): + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter("always") self.assertEqual(sweden.changes, {"name": "Norway"}) + assert w[0].category == DeprecationWarning def test_patch_no_changes(self): Country = warlock.model_factory(fixture) |