Skip to content

Commit

Permalink
Improve test and comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus authored and 0xDEC0DE committed Jul 12, 2024
1 parent b8bf7ed commit 3670225
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/_pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions testing/python/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 3670225

Please sign in to comment.