1
0
mirror of https://github.com/fedora-python/tox-current-env.git synced 2024-12-25 09:36:13 +01:00

Handle tox -r after --current-env

This commit is contained in:
Miro Hrončok 2019-07-17 18:54:39 +02:00
parent 0a281f94b1
commit c9fe58c8eb
2 changed files with 5 additions and 2 deletions

View File

@ -56,10 +56,14 @@ def tox_testenv_create(venv, action):
# Remove the rest of the virtualenv. # Remove the rest of the virtualenv.
link = venv.envconfig.get_envpython() link = venv.envconfig.get_envpython()
target = sys.executable target = sys.executable
shutil.rmtree(os.path.dirname(link), ignore_errors=True) shutil.rmtree(os.path.dirname(os.path.dirname(link)), ignore_errors=True)
os.makedirs(os.path.dirname(link)) os.makedirs(os.path.dirname(link))
os.symlink(target, link) os.symlink(target, link)
return True return True
else:
link = venv.envconfig.get_envpython()
shutil.rmtree(os.path.dirname(os.path.dirname(link)), ignore_errors=True)
return None # let tox handle the rest
@tox.hookimpl @tox.hookimpl

View File

@ -66,7 +66,6 @@ def test_regular_after_current():
assert f"/.tox/{NATIVE_TOXENV}/bin/python" in result.stdout.splitlines()[0] assert f"/.tox/{NATIVE_TOXENV}/bin/python" in result.stdout.splitlines()[0]
@pytest.mark.xfail(reason="Regular tox refuses to remove our fake virtualenv")
def test_regular_recreate_after_current(): def test_regular_recreate_after_current():
tox("-e", NATIVE_TOXENV, "--current-env") tox("-e", NATIVE_TOXENV, "--current-env")
tox("-re", NATIVE_TOXENV, prune=False) tox("-re", NATIVE_TOXENV, prune=False)