summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Willhaus <mail@janwillhaus.de>2019-11-02 22:55:07 +0100
committerJan Willhaus <mail@janwillhaus.de>2019-11-02 22:55:07 +0100
commit6555753beb2c5d43d604f656c892eeb186ceb4f7 (patch)
tree4fabb9001584ef5e0ca3a8abfd0c4cd4fa7da7cf
parente1cc47b421a054af8a758bd0fd7af4fb6fecac31 (diff)
downloadwarlock-add_tests_for_deprecation_warnings_on_model.changes.tar.gz
Use Python 2.7-friendly version of assessing warningsadd_tests_for_deprecation_warnings_on_model.changes
-rw-r--r--tests/test_core.py13
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)