diff --git a/src/tox_current_env/hooks.py b/src/tox_current_env/hooks.py index c9854b7..08ef9c9 100644 --- a/src/tox_current_env/hooks.py +++ b/src/tox_current_env/hooks.py @@ -56,10 +56,14 @@ def tox_testenv_create(venv, action): # Remove the rest of the virtualenv. link = venv.envconfig.get_envpython() 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.symlink(target, link) 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 diff --git a/tests/test_integration.py b/tests/test_integration.py index 2d7fdfd..2dcda1a 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -66,7 +66,6 @@ def test_regular_after_current(): 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(): tox("-e", NATIVE_TOXENV, "--current-env") tox("-re", NATIVE_TOXENV, prune=False)