Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mypy/test/test_diff_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def test_diff_cache_produces_valid_json(self) -> None:
src_dir = tempfile.mkdtemp()
output_file = os.path.join(tempfile.mkdtemp(), "diff.json")
env = os.environ.copy()
env["PYTHONPATH"] = PREFIX
existing = env.get("PYTHONPATH")
env["PYTHONPATH"] = PREFIX + (os.pathsep + existing if existing else "")
try:
cache1 = os.path.join(src_dir, "cache1")
cache2 = os.path.join(src_dir, "cache2")
Expand Down
6 changes: 5 additions & 1 deletion mypy/test/testcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ def run_case_once(
# Make sure we are running tests with current worktree files, *not* with
# an installed version of mypy.
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
worker_env["PYTHONPATH"] = os.pathsep.join([root_dir, plugin_dir])
new_python_path = os.pathsep.join([root_dir, plugin_dir])
existing = worker_env.get("PYTHONPATH")
worker_env["PYTHONPATH"] = new_python_path + (
os.pathsep + existing if existing else ""
)
worker_env["MYPY_TEST_PREFIX"] = root_dir
worker_env["MYPY_ALT_LIB_PATH"] = test_temp_dir

Expand Down
3 changes: 3 additions & 0 deletions mypy/test/testcmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ def test_python_cmdline(testcase: DataDrivenTestCase, step: int) -> None:
env.pop("COLUMNS", None)
extra_path = os.path.join(os.path.abspath(test_temp_dir), "pypath")
# Use the same mypy installation as pytest, including the compiled wheel in CI.
existing = env.get("PYTHONPATH")
env["PYTHONPATH"] = os.path.dirname(os.path.abspath(mypy.__path__[0]))
if os.path.isdir(extra_path):
env["PYTHONPATH"] += os.pathsep + extra_path
if existing:
env["PYTHONPATH"] += os.pathsep + existing
cwd = os.path.join(test_temp_dir, custom_cwd or "")
args = [arg.replace("$CWD", os.path.abspath(cwd)) for arg in args]
process = subprocess.Popen(
Expand Down
3 changes: 2 additions & 1 deletion mypy/test/testdaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def run_cmd(input: str) -> tuple[int, str]:
if input.startswith("mypy "):
input = sys.executable + " -m" + input
env = os.environ.copy()
env["PYTHONPATH"] = PREFIX
existing = env.get("PYTHONPATH")
env["PYTHONPATH"] = PREFIX + (os.pathsep + existing if existing else "")
try:
output = subprocess.check_output(
input, shell=True, stderr=subprocess.STDOUT, text=True, cwd=test_temp_dir, env=env
Expand Down
2 changes: 1 addition & 1 deletion mypyc/test/librt_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def run_with_librt(
librt_path = get_librt_path(experimental, opt_level=opt_level)
# Prepend librt path to PYTHONPATH
env = os.environ.copy()
existing = env.get("PYTHONPATH", "")
existing = env.get("PYTHONPATH")
env["PYTHONPATH"] = librt_path + (os.pathsep + existing if existing else "")

return subprocess.run(
Expand Down
3 changes: 2 additions & 1 deletion mypyc/test/test_commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ def run_case(self, testcase: DataDrivenTestCase) -> None:
f.write(text)

env = os.environ.copy()
env["PYTHONPATH"] = base_path
existing = env.get("PYTHONPATH")
env["PYTHONPATH"] = base_path + (os.pathsep + existing if existing else "")

out = b""
try:
Expand Down
3 changes: 2 additions & 1 deletion mypyc/test/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def test_c_generation_does_not_import_setuptools(self) -> None:
with open(os.path.join(tmpdir, "a.py"), "w") as f:
f.write("def f(x: int) -> int:\n return x + 1\n")
env = os.environ.copy()
env["PYTHONPATH"] = PREFIX + os.pathsep + env.get("PYTHONPATH", "")
existing = env.get("PYTHONPATH")
env["PYTHONPATH"] = PREFIX + (os.pathsep + existing if existing else "")
result = subprocess.run(
[sys.executable, "-c", script], cwd=tmpdir, env=env, capture_output=True, text=True
)
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ To control which tests are run and how, you can use the `-k` switch:
You can also run the type checker for manual testing without
installing it by setting up the Python module search path suitably:

export PYTHONPATH=$PWD
export PYTHONPATH=$PWD:$PYTHONPATH
python3 -m mypy PROGRAM.py

You will have to manually install the `typing` module if you're running Python
Expand Down
Loading