diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 16:29:01 +0000 |
commit | 35a96bde514a8897f6f0fcc41c5833bf63df2e2a (patch) | |
tree | 657d15a03cc46bd099fc2c6546a7a4ad43815d9f /share/extensions/tests/test_inkex_deprecated.py | |
parent | Initial commit. (diff) | |
download | inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.tar.xz inkscape-35a96bde514a8897f6f0fcc41c5833bf63df2e2a.zip |
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'share/extensions/tests/test_inkex_deprecated.py')
-rw-r--r-- | share/extensions/tests/test_inkex_deprecated.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/share/extensions/tests/test_inkex_deprecated.py b/share/extensions/tests/test_inkex_deprecated.py new file mode 100644 index 0000000..b569a76 --- /dev/null +++ b/share/extensions/tests/test_inkex_deprecated.py @@ -0,0 +1,36 @@ +# coding=utf-8 +"""Test base inkex module functionality""" +from __future__ import absolute_import, print_function, unicode_literals + +import warnings + +from inkex.deprecated import _deprecated +from inkex.tester import TestCase + +class DeprecatedTests(TestCase): + """Test ways in which we deprecate code""" + maxDiff = 10000 + + def assertDeprecated(self, call, msg, *args, **kwargs): # pylint: disable=invalid-name + """Catch deprecation warnings and test their output""" + with warnings.catch_warnings(record=True) as warns: + warnings.simplefilter("always") + call(*args, **kwargs) + if msg is None: + self.assertFalse(warns, "Expected no warnings, got warnings!") + else: + self.assertTrue(warns, "No warning was returned, expected warning!") + if msg is not False: + self.assertEqual(str(warns[0].category.__name__), "DeprecationWarning") + return warns[0] + + def test_warning(self): + """What happens when we deprecate things""" + self.assertDeprecated(_deprecated, None, "", stack=0, level=0) + self.assertDeprecated(_deprecated, "FOO", "FOO", stack=0, level=1) + + def test_traceback(self): + """Traceback is possible for deprecation warnings""" + warn = self.assertDeprecated(_deprecated, False, "BAR", stack=0, level=2) + self.assertIn("inkex/deprecated.py", str(warn.message)) + self.assertIn("test_inkex_deprecated.py", str(warn.message)) |