mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
Add another refactoring test
This commit is contained in:
@@ -78,7 +78,7 @@ def _calculate_rename(path, new_name):
|
||||
dir_ = dirname(path)
|
||||
if name in ('__init__.py', '__init__.pyi'):
|
||||
parent_dir = dirname(dir_)
|
||||
return dir_, join(parent_dir, new_name, name)
|
||||
return dir_, join(parent_dir, new_name)
|
||||
ending = re.search(r'\.pyi?$', name).group(0)
|
||||
return path, join(dir_, new_name + ending)
|
||||
|
||||
|
||||
2
test/refactor/import_tree/pkgx/__init__.py
Normal file
2
test/refactor/import_tree/pkgx/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def pkgx():
|
||||
pass
|
||||
1
test/refactor/import_tree/pkgx/__init__.pyi
Normal file
1
test/refactor/import_tree/pkgx/__init__.pyi
Normal file
@@ -0,0 +1 @@
|
||||
def pkgx() -> int: ...
|
||||
1
test/refactor/import_tree/pkgx/mod.pyi
Normal file
1
test/refactor/import_tree/pkgx/mod.pyi
Normal file
@@ -0,0 +1 @@
|
||||
from . import pkgx
|
||||
1
test/refactor/import_tree/pkgx/mod2.py
Normal file
1
test/refactor/import_tree/pkgx/mod2.py
Normal file
@@ -0,0 +1 @@
|
||||
from .. import pkgx
|
||||
@@ -75,3 +75,47 @@ rename to /home/dave/source/jedi/test/refactor/import_tree/renamedm.py
|
||||
#? 0 renamedm
|
||||
-mod
|
||||
+renamedm
|
||||
# -------------------------------------------------- in-package-with-stub
|
||||
#? 31 renamedm
|
||||
from import_tree.pkgx import pkgx
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
--- /home/dave/source/jedi/test/refactor/import_tree/pkgx/__init__.py
|
||||
+++ /home/dave/source/jedi/test/refactor/import_tree/pkgx/__init__.py
|
||||
@@ -1,3 +1,3 @@
|
||||
-def pkgx():
|
||||
+def renamedm():
|
||||
pass
|
||||
--- /home/dave/source/jedi/test/refactor/import_tree/pkgx/__init__.pyi
|
||||
+++ /home/dave/source/jedi/test/refactor/import_tree/pkgx/__init__.pyi
|
||||
@@ -1,2 +1,2 @@
|
||||
-def pkgx() -> int: ...
|
||||
+def renamedm() -> int: ...
|
||||
--- /home/dave/source/jedi/test/refactor/import_tree/pkgx/mod.pyi
|
||||
+++ /home/dave/source/jedi/test/refactor/import_tree/pkgx/mod.pyi
|
||||
@@ -1,2 +1,2 @@
|
||||
-from . import pkgx
|
||||
+from . import renamedm
|
||||
--- /home/dave/source/jedi/test/refactor/rename.py
|
||||
+++ /home/dave/source/jedi/test/refactor/rename.py
|
||||
@@ -1,3 +1,3 @@
|
||||
#? 31 renamedm
|
||||
-from import_tree.pkgx import pkgx
|
||||
+from import_tree.pkgx import renamedm
|
||||
# -------------------------------------------------- package-with-stub
|
||||
#? 18 renamedp
|
||||
from import_tree.pkgx
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
rename from /home/dave/source/jedi/test/refactor/import_tree/pkgx
|
||||
rename to /home/dave/source/jedi/test/refactor/import_tree/renamedp
|
||||
--- /home/dave/source/jedi/test/refactor/import_tree/pkgx/mod2.py
|
||||
+++ /home/dave/source/jedi/test/refactor/import_tree/pkgx/mod2.py
|
||||
@@ -1,2 +1,2 @@
|
||||
-from .. import pkgx
|
||||
+from .. import renamedp
|
||||
--- /home/dave/source/jedi/test/refactor/rename.py
|
||||
+++ /home/dave/source/jedi/test/refactor/rename.py
|
||||
@@ -1,3 +1,3 @@
|
||||
#? 18 renamedp
|
||||
-from import_tree.pkgx
|
||||
+from import_tree.renamedp
|
||||
# -------------------------------------------------- weird-package-mix
|
||||
|
||||
@@ -3,6 +3,7 @@ import os
|
||||
import pytest
|
||||
|
||||
from . import helpers
|
||||
from jedi.inference.utils import indent_block
|
||||
|
||||
|
||||
def assert_case_equal(case, actual, desired):
|
||||
@@ -15,9 +16,11 @@ def assert_case_equal(case, actual, desired):
|
||||
"""
|
||||
assert actual == desired, """
|
||||
Test %r failed.
|
||||
actual = %s
|
||||
desired = %s
|
||||
""" % (case, actual, desired)
|
||||
actual =
|
||||
%s
|
||||
desired =
|
||||
%s
|
||||
""" % (case, indent_block(actual), indent_block(desired))
|
||||
|
||||
|
||||
def assert_static_analysis(case, actual, desired):
|
||||
|
||||
Reference in New Issue
Block a user