diff options
Diffstat (limited to 'tests/unittest_modutils.py')
-rw-r--r-- | tests/unittest_modutils.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/unittest_modutils.py b/tests/unittest_modutils.py index b5c41bf0..9b3cecf4 100644 --- a/tests/unittest_modutils.py +++ b/tests/unittest_modutils.py @@ -10,6 +10,7 @@ # Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk> # Copyright (c) 2019 Hugo van Kemenade <hugovk@users.noreply.github.com> # Copyright (c) 2019 markmcclain <markmcclain@users.noreply.github.com> +# Copyright (c) 2020 Peter Kolbus <peter.kolbus@gmail.com> # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html # For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER @@ -82,7 +83,7 @@ class LoadModuleFromNameTest(unittest.TestCase): def test_raise_load_module_from_name_1(self): self.assertRaises( - ImportError, modutils.load_module_from_name, "os.path", use_sys=0 + ImportError, modutils.load_module_from_name, "_this_module_does_not_exist_" ) @@ -297,6 +298,23 @@ class IsRelativeTest(unittest.TestCase): def test_knownValues_is_relative_3(self): self.assertFalse(modutils.is_relative("astroid", astroid.__path__[0])) + def test_deep_relative(self): + self.assertTrue(modutils.is_relative("ElementTree", xml.etree.__path__[0])) + + def test_deep_relative2(self): + self.assertFalse(modutils.is_relative("ElementTree", xml.__path__[0])) + + def test_deep_relative3(self): + self.assertTrue(modutils.is_relative("etree.ElementTree", xml.__path__[0])) + + def test_deep_relative4(self): + self.assertTrue(modutils.is_relative("etree.gibberish", xml.__path__[0])) + + def test_is_relative_bad_path(self): + self.assertFalse( + modutils.is_relative("ElementTree", os.path.join(xml.__path__[0], "ftree")) + ) + class GetModuleFilesTest(unittest.TestCase): def test_get_module_files_1(self): |