diff --git a/src/_pytest/fixtures.py b/src/_pytest/fixtures.py index cda4f0c42f3..a55ccf3ed51 100644 --- a/src/_pytest/fixtures.py +++ b/src/_pytest/fixtures.py @@ -1057,9 +1057,8 @@ def execute(self, request: SubRequest) -> FixtureValue: if self.cached_result is not None: cache_key = self.cached_result[1] - # note: `__eq__` is not required to return a bool, and sometimes - # doesn't, e.g., numpy arrays (#6497). Coerce the comparison - # into a bool, and if that fails, fall back to an identity check. + # Coerce the comparison into a bool (#12600), and if that fails, fall back to an identity check: + # `__eq__` is not required to return a bool, and sometimes doesn't, e.g., numpy arrays (#6497). try: cache_hit = bool(my_cache_key == cache_key) except (ValueError, RuntimeError): diff --git a/testing/python/fixtures.py b/testing/python/fixtures.py index 2761d9e19f4..8d2646309a8 100644 --- a/testing/python/fixtures.py +++ b/testing/python/fixtures.py @@ -1568,9 +1568,9 @@ def test_parameterized_fixture_caching(self, pytester: Pytester) -> None: def pytest_generate_tests(metafunc): if "my_fixture" in metafunc.fixturenames: - param = "d%s" % "1" - print("param id=%d" % id(param), flush=True) - metafunc.parametrize("my_fixture", [param, "d2"], indirect=True) + # Use unique objects for parametrization (as opposed to small strings + # and small integers which are singletons). + metafunc.parametrize("my_fixture", [[1], [2]], indirect=True) @pytest.fixture(scope='session') def my_fixture(request):