From 44ba7da143cc60f9075e733e019c1a6b65b71ebd Mon Sep 17 00:00:00 2001 From: Nick Smith Date: Fri, 24 Feb 2017 15:13:31 -0800 Subject: [PATCH] test(refactor): add test for moving module referenced by relative import Add a test case verifying that moving a module referenced via an explicit relative import correctly updates the import statement in the importing module to an absolute import pointing to the new destination package. Fixes #202 --- ropetest/refactor/movetest.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ropetest/refactor/movetest.py b/ropetest/refactor/movetest.py index 90f235d32..2e467b82b 100644 --- a/ropetest/refactor/movetest.py +++ b/ropetest/refactor/movetest.py @@ -801,6 +801,19 @@ def test_moving_modules_normal_import(self) -> None: print(pkg2.pkg3.pkg4.origin_module_in_pkg)""") self.assertEqual(expected, self.mod1.read()) + def test_moving_module_referenced_by_relative_import(self) -> None: + self.mod4.write(dedent("""\ + from .mod5 import a + print(a) + """)) + self.mod5.write("a = 1\n") + self._move(self.mod5, None, self.destination_pkg_root) + expected = dedent("""\ + from destination_pkg_root.mod5 import a + print(a) + """) + self.assertEqual(expected, self.mod4.read()) + def test_moving_package_with_from_and_normal_imports(self) -> None: code = dedent("""\ from pkg import mod4