Skip to content

Commit

Permalink
Add unit test for envreport PYTHONPATH handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitrii Sutiagin committed Nov 4, 2022
1 parent 429ca5a commit 7a07c12
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/unit/test_venv.py
@@ -1,5 +1,6 @@
import os
import sys
from unittest.mock import MagicMock, patch

import py
import pytest
Expand All @@ -14,6 +15,7 @@
VirtualEnv,
getdigest,
prepend_shebang_interpreter,
tox_runenvreport,
tox_testenv_create,
tox_testenv_install_deps,
)
Expand Down Expand Up @@ -1233,3 +1235,15 @@ def test_path_change(tmpdir, mocksession, newconfig, monkeypatch):
path = x.env["PATH"]
assert os.environ["PATH"] in path
assert path.endswith(str(venv.envconfig.config.toxinidir) + "/bin")


@pytest.mark.parametrize("pythonpath", (None, "blah"))
@patch("tox.venv.VirtualEnv._get_os_environ")
def test_runenvreport_pythonpath_discarded(mock_os_environ, pythonpath, newmocksession):
mocksession = newmocksession([], "")
venv = mocksession.getvenv("python")
action = MagicMock()
mock_os_environ.return_value = dict(PYTHONPATH=pythonpath) if pythonpath else {}
with patch.object(venv, "_pcall") as mock_pcall:
tox_runenvreport(venv, action)
assert "PYTHONPATH" not in mock_pcall.mock_calls[0].kwargs["env"]

0 comments on commit 7a07c12

Please sign in to comment.