mirror of
				https://github.com/fedora-python/tox-current-env.git
				synced 2025-10-30 16:02:19 +01:00 
			
		
		
		
	Only use tox_cleanup hook when it is possible
This commit is contained in:
		| @@ -85,10 +85,15 @@ def unsupported_raise(config, venv): | ||||
|         return | ||||
|     regular = not (config.option.current_env or config.option.print_deps_only) | ||||
|     if regular and is_current_env_link(venv): | ||||
|         if hasattr(tox.hookspecs, "tox_cleanup"): | ||||
|             raise tox.exception.ConfigError( | ||||
|                 "Looks like previous --current-env or --print-deps-only tox run didn't finish the cleanup. " | ||||
|                 "Run tox run with --recreate (-r) or manually remove the environment in .tox." | ||||
|             ) | ||||
|         else: | ||||
|             raise tox.exception.ConfigError( | ||||
|                 "Regular tox run after --current-env or --print-deps-only tox run is not supported without --recreate (-r)." | ||||
|             ) | ||||
|     elif config.option.current_env and is_proper_venv(venv): | ||||
|         raise tox.exception.ConfigError( | ||||
|             "--current-env after regular tox run is not supported without --recreate (-r)." | ||||
| @@ -166,6 +171,8 @@ def tox_runtest(venv, redirect): | ||||
|         return True | ||||
|  | ||||
|  | ||||
| if hasattr(tox.hookspecs, "tox_cleanup"): | ||||
|  | ||||
|     @tox.hookimpl | ||||
|     def tox_cleanup(session): | ||||
|         """Remove the fake virtualenv not to collide with regular tox | ||||
|   | ||||
| @@ -6,6 +6,8 @@ import subprocess | ||||
| import sys | ||||
| import textwrap | ||||
|  | ||||
| from packaging import version | ||||
|  | ||||
| import pytest | ||||
|  | ||||
|  | ||||
| @@ -37,6 +39,8 @@ def is_available(python): | ||||
|     return True | ||||
|  | ||||
|  | ||||
| TOX_VERSION = version.parse(tox("--version").stdout.split(" ")[0]) | ||||
|  | ||||
| needs_py3678 = pytest.mark.skipif( | ||||
|     not is_available("python3.6") | ||||
|     or not is_available("python3.7") | ||||
| @@ -44,6 +48,10 @@ needs_py3678 = pytest.mark.skipif( | ||||
|     reason="This test needs all of python3.6, python3.7 and python3.8 to be available in $PATH", | ||||
| ) | ||||
|  | ||||
| needs_tox38 = pytest.mark.skipif( | ||||
|     TOX_VERSION < version.parse("3.8"), reason="This test needs at least tox 3.8" | ||||
| ) | ||||
|  | ||||
|  | ||||
| def test_native_toxenv_current_env(): | ||||
|     result = tox("-e", NATIVE_TOXENV, "--current-env") | ||||
| @@ -195,6 +203,7 @@ def test_regular_run_native_toxenv(): | ||||
|         assert len(list(sitelib.glob(f"{pkg}-*.dist-info"))) == 1 | ||||
|  | ||||
|  | ||||
| @needs_tox38 | ||||
| def test_regular_after_current_is_supported(): | ||||
|     result = tox("-e", NATIVE_TOXENV, "--current-env") | ||||
|     assert result.stdout.splitlines()[0] == NATIVE_EXECUTABLE | ||||
| @@ -214,6 +223,7 @@ def test_regular_after_killed_current_is_not_supported(): | ||||
|     assert "--recreate" in result.stderr | ||||
|  | ||||
|  | ||||
| @needs_tox38 | ||||
| def test_regular_after_first_deps_only_is_supported(): | ||||
|     result = tox("-e", NATIVE_TOXENV, "--print-deps-only") | ||||
|     assert result.stdout.splitlines()[0] == "six" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user