From e83bfa650da28924ff660b2c28116be00b06dd90 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 22 Feb 2024 18:12:27 -0500 Subject: [PATCH] fix(types): make the passthrough general Signed-off-by: Henry Schreiner --- src/build/env.py | 2 +- tests/conftest.py | 5 +++++ tests/test_env.py | 3 +++ tests/test_main.py | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/build/env.py b/src/build/env.py index 70fe8b1a..cb6dbd70 100644 --- a/src/build/env.py +++ b/src/build/env.py @@ -70,7 +70,7 @@ def _minimum_pip_version() -> str: return '19.1.0' -def _has_valid_pip(**distargs: str) -> bool: +def _has_valid_pip(**distargs: object) -> bool: """ Given a path, see if Pip is present and return True if the version is sufficient for build, False if it is not. diff --git a/tests/conftest.py b/tests/conftest.py index ecc25383..8f989d68 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -65,6 +65,11 @@ def is_integration(item): return os.path.basename(item.location[0]) == 'test_integration.py' +@pytest.fixture() +def local_pip(monkeypatch): + monkeypatch.setattr(build.env, '_valid_global_pip', lambda: None) + + @pytest.fixture(scope='session', autouse=True) def ensure_syconfig_vars_created(): # the config vars are globally cached and may use get_path, make sure they are created diff --git a/tests/test_env.py b/tests/test_env.py index 41d1f478..de63c42b 100644 --- a/tests/test_env.py +++ b/tests/test_env.py @@ -26,6 +26,7 @@ def test_isolation(): @pytest.mark.isolated +@pytest.mark.usefixtures('local_pip') def test_isolated_environment_install(mocker): with build.env.DefaultIsolatedEnv() as env: mocker.patch('build.env._subprocess') @@ -117,6 +118,7 @@ def test_isolated_env_log(mocker, caplog, package_test_flit): @pytest.mark.isolated +@pytest.mark.usefixtures('local_pip') def test_default_pip_is_never_too_old(): with build.env.DefaultIsolatedEnv() as env: version = subprocess.check_output( @@ -130,6 +132,7 @@ def test_default_pip_is_never_too_old(): @pytest.mark.isolated @pytest.mark.parametrize('pip_version', ['20.2.0', '20.3.0', '21.0.0', '21.0.1']) @pytest.mark.parametrize('arch', ['x86_64', 'arm64']) +@pytest.mark.usefixtures('local_pip') def test_pip_needs_upgrade_mac_os_11(mocker, pip_version, arch): SimpleNamespace = collections.namedtuple('SimpleNamespace', 'version') diff --git a/tests/test_main.py b/tests/test_main.py index 8edc3094..2ca18e47 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -342,6 +342,7 @@ def main_reload_styles(): ], ids=['no-color', 'color'], ) +@pytest.mark.usefixtures('local_pip') def test_output_env_subprocess_error( mocker, monkeypatch,