Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
  • Loading branch information
gaborbernat committed Feb 21, 2020
1 parent ac7b066 commit 7df4308
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 5 additions & 4 deletions tests/unit/discovery/py_info/test_py_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,26 @@ def test_py_info_cached_symlink_error(mocker, tmp_path):
def test_py_info_cache_clear(mocker, tmp_path):
spy = mocker.spy(cached_py_info, "_run_subprocess")
assert PythonInfo.from_exe(sys.executable) is not None
assert spy.call_count == 2 # at least two, one for the venv, one more for the host
assert spy.call_count >= 2 # at least two, one for the venv, one more for the host
PythonInfo.clear_cache()
assert PythonInfo.from_exe(sys.executable) is not None
assert spy.call_count == 4
assert spy.call_count >= 4


@pytest.mark.skipif(not fs_supports_symlink(), reason="symlink is not supported")
def test_py_info_cached_symlink(mocker, tmp_path):
spy = mocker.spy(cached_py_info, "_run_subprocess")
first_result = PythonInfo.from_exe(sys.executable)
assert first_result is not None
assert spy.call_count == 2 # at least two, one for the venv, one more for the host
count = spy.call_count
assert count >= 2 # at least two, one for the venv, one more for the host

new_exe = tmp_path / "a"
new_exe.symlink_to(sys.executable)
new_exe_str = str(new_exe)
second_result = PythonInfo.from_exe(new_exe_str)
assert second_result.executable == new_exe_str
assert spy.call_count == 3 # no longer needed the host invocation, but the new symlink is must
assert spy.call_count == count + 1 # no longer needed the host invocation, but the new symlink is must


PyInfoMock = namedtuple("PyInfoMock", ["implementation", "architecture", "version_info"])
Expand Down
2 changes: 0 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ passenv = https_proxy http_proxy no_proxy HOME PYTEST_* PIP_* CI_RUN TERM
extras = testing
install_command = python -m pip install {opts} {packages} --disable-pip-version-check
commands =
python -m site
python -m pip list
python -c 'from os.path import sep; file = open(r"{envsitepackagesdir}\{\}coverage-virtualenv.pth".format(sep), "w"); file.write("import coverage; coverage.process_startup()"); file.close()'
python -m coverage erase

Expand Down

0 comments on commit 7df4308

Please sign in to comment.