diff options
author | Laurent Peuch <cortex@worlddomination.be> | 2020-05-06 14:20:08 +0200 |
---|---|---|
committer | Laurent Peuch <cortex@worlddomination.be> | 2020-05-06 14:20:08 +0200 |
commit | 324419e23b73f2269fff4d44e1457d7d3bfbf66d (patch) | |
tree | e0ddff710df5b40726b751bc8dc377454b18995f /test/test_modutils.py | |
parent | 49dc54a7c761ca4acbef6d2104f8a45a1d5a9cb1 (diff) | |
download | logilab-common-324419e23b73f2269fff4d44e1457d7d3bfbf66d.tar.gz |
[deprecation/fix] correctly automatically get the module in which deprecation utils are called
There was a missmatched combination of:
* the frame wasn't always correctly grabbed
* grabbing the frame in the situation of a decorator didn't make any sens, so
switch to func.__module__
* the tests were bad and expected "[logilab.common]" while it should have been
"[test_deprecation]" because it was there that the depreciation was declared
Diffstat (limited to 'test/test_modutils.py')
-rw-r--r-- | test/test_modutils.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/test/test_modutils.py b/test/test_modutils.py index cd639e1..bcffe07 100644 --- a/test/test_modutils.py +++ b/test/test_modutils.py @@ -90,12 +90,15 @@ class get_module_part_tc(ModutilsTestCase): """given a dotted name return the module part of the name""" def test_knownValues_get_module_part_1(self): - self.assertEqual(modutils.get_module_part('logilab.common.modutils'), - 'logilab.common.modutils') + self.assertEqual( + modutils.get_module_part("logilab.common.modutils"), "logilab.common.modutils" + ) def test_knownValues_get_module_part_2(self): - self.assertEqual(modutils.get_module_part('logilab.common.modutils.get_module_part'), - 'logilab.common.modutils') + self.assertEqual( + modutils.get_module_part("logilab.common.modutils.get_module_part"), + "logilab.common.modutils", + ) def test_knownValues_get_module_part_3(self): """relative import from given file""" @@ -120,10 +123,13 @@ class modpath_from_file_tc(ModutilsTestCase): def test_knownValues_modpath_from_file_1(self): with warnings.catch_warnings(record=True) as warns: - self.assertEqual(modutils.modpath_from_file(modutils.__file__), - ['logilab', 'common', 'modutils']) - self.assertIn('[logilab.common] you should avoid using modpath_from_file()', - [str(w.message) for w in warns]) + self.assertEqual( + modutils.modpath_from_file(modutils.__file__), ["logilab", "common", "modutils"] + ) + self.assertIn( + "[logilab.common.modutils] you should avoid using modpath_from_file()", + [str(w.message) for w in warns], + ) def test_knownValues_modpath_from_file_2(self): self.assertEqual(modutils.modpath_from_file('unittest_modutils.py', |