Implement all remaining Path issues and use it instead of strings

This commit is contained in:
Dave Halter
2020-07-12 01:14:00 +02:00
parent db0e90763b
commit 480a464179
23 changed files with 131 additions and 97 deletions

View File

@@ -22,7 +22,7 @@ def test_preload_modules():
# Filter the typeshed parser cache.
typeshed_cache_count = sum(
1 for path in grammar_cache
if path is not None and path.startswith(typeshed.TYPESHED_PATH)
if path is not None and str(path).startswith(str(typeshed.TYPESHED_PATH))
)
# +1 for None module (currently used)
assert len(grammar_cache) - typeshed_cache_count == len(modules) + 1
@@ -210,11 +210,11 @@ def test_goto_follow_imports(Script):
import inspect
inspect.isfunction""")
definition, = Script(code).goto(column=0, follow_imports=True)
assert 'inspect.py' in definition.module_path
assert definition.module_path.name == 'inspect.py'
assert (definition.line, definition.column) == (1, 0)
definition, = Script(code).goto(follow_imports=True)
assert 'inspect.py' in definition.module_path
assert definition.module_path.name == 'inspect.py'
assert (definition.line, definition.column) > (1, 0)
code = '''def param(p): pass\nparam(1)'''
@@ -245,11 +245,11 @@ def test_goto_module(Script):
assert module.module_path == expected
base_path = get_example_dir('simple_import')
path = os.path.join(base_path, '__init__.py')
path = base_path.joinpath('__init__.py')
check(1, os.path.join(base_path, 'module.py'))
check(1, os.path.join(base_path, 'module.py'), follow_imports=True)
check(5, os.path.join(base_path, 'module2.py'))
check(1, base_path.joinpath('module.py'))
check(1, base_path.joinpath('module.py'), follow_imports=True)
check(5, base_path.joinpath('module2.py'))
def test_goto_definition_cursor(Script):