From 6555753beb2c5d43d604f656c892eeb186ceb4f7 Mon Sep 17 00:00:00 2001 From: Jan Willhaus Date: Sat, 2 Nov 2019 22:55:07 +0100 Subject: Use Python 2.7-friendly version of assessing warnings --- tests/test_core.py | 13 ++++++++++--- 1 file 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) -- cgit v1.2.1