Get rid of cwd modifications in tests

This commit is contained in:
Dave Halter
2020-02-06 01:47:34 +01:00
parent f2722952e7
commit 14ac0512a9
10 changed files with 55 additions and 46 deletions
+3 -2
View File
@@ -191,18 +191,19 @@ class Importer(object):
import_path = base + tuple(import_path)
else:
path = module_context.py__file__()
project_path = self._inference_state.project._path
import_path = list(import_path)
if path is None:
# If no path is defined, our best guess is that the current
# file is edited by a user on the current working
# directory. We need to add an initial path, because it
# will get removed as the name of the current file.
directory = os.getcwd()
directory = project_path
else:
directory = os.path.dirname(path)
base_import_path, base_directory = _level_to_base_import_path(
self._inference_state.project._path, directory, level,
project_path, directory, level,
)
if base_directory is None:
# Everything is lost, the relative import does point