summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>2017-01-20 16:07:39 +0100
committerPhilippe Pepiot <philippe.pepiot@logilab.fr>2017-01-20 16:07:39 +0100
commit1f42d92dbca788c4ab7750ae8359b974134cf595 (patch)
tree3dd9f331ed43500907045ab01677438e71b6bb3a /test
parent6c9ed73a6a26affe441840b2e7e37c397a6d2221 (diff)
downloadlogilab-common-1f42d92dbca788c4ab7750ae8359b974134cf595.tar.gz
[modutils] deprecate modpath_from_file
The method will likely fail if there somes symlinks in your python environment and will certainly fail on a file that isn't in sys.path (like custom importers using sys.meta_path).
Diffstat (limited to 'test')
-rw-r--r--test/unittest_modutils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/unittest_modutils.py b/test/unittest_modutils.py
index d1fcaf9..ec2a5c8 100644
--- a/test/unittest_modutils.py
+++ b/test/unittest_modutils.py
@@ -21,6 +21,7 @@ unit tests for module modutils (module manipulation utilities)
import doctest
import sys
+import warnings
try:
__file__
except NameError:
@@ -117,8 +118,11 @@ class modpath_from_file_tc(ModutilsTestCase):
""" given an absolute file path return the python module's path as a list """
def test_knownValues_modpath_from_file_1(self):
- self.assertEqual(modutils.modpath_from_file(modutils.__file__),
- ['logilab', 'common', 'modutils'])
+ with warnings.catch_warnings(record=True) as warns:
+ self.assertEqual(modutils.modpath_from_file(modutils.__file__),
+ ['logilab', 'common', 'modutils'])
+ self.assertIn('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',