Skip to content

Commit 3670225

Browse files
nicoddemus0xDEC0DE
authored andcommitted
Improve test and comment
1 parent b8bf7ed commit 3670225

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/_pytest/fixtures.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,8 @@ def execute(self, request: SubRequest) -> FixtureValue:
10571057
if self.cached_result is not None:
10581058
cache_key = self.cached_result[1]
10591059

1060-
# note: `__eq__` is not required to return a bool, and sometimes
1061-
# doesn't, e.g., numpy arrays (#6497). Coerce the comparison
1062-
# into a bool, and if that fails, fall back to an identity check.
1060+
# Coerce the comparison into a bool (#12600), and if that fails, fall back to an identity check:
1061+
# `__eq__` is not required to return a bool, and sometimes doesn't, e.g., numpy arrays (#6497).
10631062
try:
10641063
cache_hit = bool(my_cache_key == cache_key)
10651064
except (ValueError, RuntimeError):

testing/python/fixtures.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,9 +1568,9 @@ def test_parameterized_fixture_caching(self, pytester: Pytester) -> None:
15681568
15691569
def pytest_generate_tests(metafunc):
15701570
if "my_fixture" in metafunc.fixturenames:
1571-
param = "d%s" % "1"
1572-
print("param id=%d" % id(param), flush=True)
1573-
metafunc.parametrize("my_fixture", [param, "d2"], indirect=True)
1571+
# Use unique objects for parametrization (as opposed to small strings
1572+
# and small integers which are singletons).
1573+
metafunc.parametrize("my_fixture", [[1], [2]], indirect=True)
15741574
15751575
@pytest.fixture(scope='session')
15761576
def my_fixture(request):

0 commit comments

Comments
 (0)