|
10 | 10 | from asv.util import shlex_quote as quote
|
11 | 11 |
|
12 | 12 | from . import tools
|
13 |
| -from .tools import (PYTHON_VER1, PYTHON_VER2, DUMMY1_VERSION, DUMMY2_VERSIONS, WIN, HAS_PYPY, |
| 13 | +from .tools import (HAS_MAMBA, PYTHON_VER1, PYTHON_VER2, DUMMY1_VERSION, DUMMY2_VERSIONS, WIN, HAS_PYPY, |
14 | 14 | HAS_CONDA, HAS_VIRTUALENV, HAS_PYTHON_VER2, generate_test_repo)
|
15 | 15 |
|
16 | 16 |
|
@@ -958,3 +958,34 @@ def test__parse_matrix_entries():
|
958 | 958 | assert python == "2.6"
|
959 | 959 | assert requirements == {"foo": "9"}
|
960 | 960 | assert tagged_env_vars == {("build", "A"): "B", ("nobuild", "C"): "D"}
|
| 961 | + |
| 962 | + |
| 963 | +@pytest.mark.parametrize("env_type", [ |
| 964 | + pytest.param("conda", marks=pytest.mark.skipif(not HAS_CONDA, reason="Requires conda")), |
| 965 | + pytest.param("mamba", marks=pytest.mark.skipif(not HAS_MAMBA, reason="Requires mamba")) |
| 966 | +]) |
| 967 | +@pytest.mark.skipif(not HAS_PYTHON_VER2, |
| 968 | + reason="Requires two usable Python versions") |
| 969 | +def test_no_env_file_python_version(tmpdir, env_type): |
| 970 | + """Test the Python version is correct when no env file is present""" |
| 971 | + conf = config.Config() |
| 972 | + conf.env_dir = str(tmpdir.join("env")) |
| 973 | + conf.environment_type = env_type |
| 974 | + conf.pythons = [PYTHON_VER1, PYTHON_VER2] |
| 975 | + conf.matrix = {} |
| 976 | + |
| 977 | + environments = list(environment.get_environments(conf, None)) |
| 978 | + assert len(environments) == 2 |
| 979 | + |
| 980 | + for env in environments: |
| 981 | + env.create() |
| 982 | + |
| 983 | + # Get the Python version from the environment |
| 984 | + output = env.run(['--version']) |
| 985 | + # Python version output format is typically "Python X.Y.Z" |
| 986 | + installed_version = output.split()[1] |
| 987 | + # Extract just the major.minor version |
| 988 | + installed_version = '.'.join(installed_version.split('.')[:2]) |
| 989 | + |
| 990 | + assert installed_version == env.python, \ |
| 991 | + f"Expected Python version {env.python}, but got {installed_version}" |
0 commit comments