Skip to content

fix test_range_deps in plugin resolver test to not use real requests distribution#23299

Open
tdyas wants to merge 1 commit intomainfrom
tdyas/fix-plugin-resolver-test
Open

fix test_range_deps in plugin resolver test to not use real requests distribution#23299
tdyas wants to merge 1 commit intomainfrom
tdyas/fix-plugin-resolver-test

Conversation

@tdyas
Copy link
Copy Markdown
Contributor

@tdyas tdyas commented Apr 29, 2026

Overview

Modify test_range_deps in src/python/pants/init/plugin_resolver_test.py to not use requests as the transitive dependency to verify the plugin resolver's behavior. Instead, use a non-existent distribution because otherwise the version of requests loaded in the test environment's sys.path could affect the test (and cause a spurious failure).

Motivation is this build failure in this other PR:

_______________________________ test_range_deps ________________________________

rule_runner = RuleRunner(build_root=/tmp/_BUILD_ROOTfn0lzflq)

    def test_range_deps(rule_runner: RuleRunner) -> None:
        # Test that when a plugin has a range dependency, specifying a working set constrains
        # to a particular version, where otherwise we would get the highest released (2.27.1 in
        # this case).
        with plugin_resolution(
            rule_runner,
            plugins=[Plugin("jane", "3.4.5", ["requests>=2.25.1,<2.28.0"])],
            existing_distributions=[MockDistribution(name="requests", version=Version("2.26.0"))],
            # Because we're resolving real distributions, we enable access to pypi.
            use_pypi=True,
        ) as (
            _,
            _,
            _,
            _,
        ):
            dist = importlib.metadata.distribution("requests")
>           assert "2.27.1" == dist.version
E           AssertionError: assert equals failed
E             '2.27.1'  '2.32.5'

src/python/pants/init/plugin_resolver_test.py:360: AssertionError
=============================== warnings summary ===============================
src/python/pants/init/plugin_resolver_test.py::test_no_plugins
  /opt/hostedtoolcache/Python/3.14.2/x64/lib/python3.14/ctypes/_endian.py:33: DeprecationWarning: Due to '_pack_', the 'ExternalHeader' Structure will use memory layout compatible with MSVC (Windows). If this is intended, set _layout_ to 'ms'. The implicit default is deprecated and slated to become an error in Python 3.19.
    super().__setattr__(attrname, value)

src/python/pants/init/plugin_resolver_test.py::test_no_plugins
  /opt/hostedtoolcache/Python/3.14.2/x64/lib/python3.14/ctypes/_endian.py:33: DeprecationWarning: Due to '_pack_', the 'PayloadHeader' Structure will use memory layout compatible with MSVC (Windows). If this is intended, set _layout_ to 'ms'. The implicit default is deprecated and slated to become an error in Python 3.19.
    super().__setattr__(attrname, value)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
- generated xml file: src.python.pants.init.plugin_resolver_test.py.tests.xml -
=========================== short test summary info ============================
FAILED src/python/pants/init/plugin_resolver_test.py::test_range_deps - AssertionError: assert equals failed
  '2.27.1'  '2.32.5'
=================== 1 failed, 7 passed, 2 warnings in 45.85s ===================

AI Disclosure

Codex (GPT-5.5) was used in authoring the solution based on my guidance of how to solve.

@tdyas tdyas added category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required [CI] PR doesn't require mention in release notes labels Apr 29, 2026
@tdyas tdyas marked this pull request as ready for review April 29, 2026 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category:internal CI, fixes for not-yet-released features, etc. release-notes:not-required [CI] PR doesn't require mention in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant