Skip to content

Commit 56326e7

Browse files
committed
fix: Adjust discovery and creator usage
* Adjust `current_fastest` fixture to correctly use `key_to_class` for creator selection. * Update `test_can_build_c_extensions` with a slow marker and xfail condition for CI. * Modify `activation_python` fixture to pass the correct creator name. * Introduce `MockCache` in `test_windows.py` for improved discovery tests. * Update `propose_interpreters` function signature in `src/virtualenv/discovery/windows/__init__.py` to accept `cache`. * Pass `cache` to `Pep514PythonInfo.from_exe`. Signed-off-by: Emre Şafak <[email protected]>
1 parent 922c7e1 commit 56326e7

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

src/virtualenv/discovery/windows/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Pep514PythonInfo(PythonInfo):
1616
"""A Python information acquired from PEP-514."""
1717

1818

19-
def propose_interpreters(spec, app_data, env):
19+
def propose_interpreters(spec, app_data, cache, env):
2020
# see if PEP-514 entries are good
2121

2222
# start with higher python versions in an effort to use the latest version available
@@ -39,7 +39,7 @@ def propose_interpreters(spec, app_data, env):
3939
interpreter = Pep514PythonInfo.from_exe(
4040
exe,
4141
app_data,
42-
app_data.cache,
42+
cache,
4343
raise_on_error=False,
4444
env=env,
4545
)

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def current_creators(session_app_data):
317317

318318
@pytest.fixture(scope="session")
319319
def current_fastest(current_creators):
320-
return "builtin" if "builtin" in current_creators else next(iter(current_creators))
320+
return "builtin" if "builtin" in current_creators.key_to_class else next(iter(current_creators.key_to_class))
321321

322322

323323
@pytest.fixture(scope="session")

tests/unit/activation/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,11 @@ def raise_on_non_source_class():
231231
@pytest.fixture(scope="session", params=[True, False], ids=["with_prompt", "no_prompt"])
232232
def activation_python(request, tmp_path_factory, special_char_name, current_fastest, session_app_data):
233233
dest = os.path.join(str(tmp_path_factory.mktemp("activation-tester-env")), special_char_name)
234-
creator_name = next(iter(current_fastest))
235234
cmd = [
236235
"--without-pip",
237236
dest,
238237
"--creator",
239-
creator_name,
238+
current_fastest,
240239
"-vv",
241240
"--no-periodic-update",
242241
"--app-data",

tests/unit/create/via_global_ref/test_build_c_ext.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import logging
4+
import os
45
import shutil
56
import subprocess
67
from pathlib import Path
@@ -16,6 +17,12 @@
1617
logger = logging.getLogger(__name__)
1718

1819

20+
@pytest.mark.slow
21+
@pytest.mark.xfail(
22+
condition=bool(os.environ.get("CI_RUN")),
23+
strict=False,
24+
reason="did not manage to setup CI to run with VC 14.1 C++ compiler, but passes locally",
25+
)
1926
def test_can_build_c_extensions(tmp_path, coverage_env, session_app_data):
2027
cache = FileCache(session_app_data.py_info, session_app_data.py_info_clear)
2128
current = PythonInfo.current_system(session_app_data, cache)

tests/unit/discovery/windows/test_windows.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66

7-
from tests.unit.discovery.util import MockAppData
7+
from tests.unit.discovery.util import MockAppData, MockCache
88
from virtualenv.discovery.py_spec import PythonSpec
99

1010

@@ -37,5 +37,5 @@ def test_propose_interpreters(string_spec, expected_exe):
3737
from virtualenv.discovery.windows import propose_interpreters # noqa: PLC0415
3838

3939
spec = PythonSpec.from_string_spec(string_spec)
40-
interpreter = next(propose_interpreters(spec, MockAppData(), env=None))
40+
interpreter = next(propose_interpreters(spec, MockAppData(), MockCache(), env=None))
4141
assert interpreter.executable == expected_exe

0 commit comments

Comments
 (0)