Skip to content

Commit 717d957

Browse files
authored
Merge pull request #4532 from jobh/fix-4531
Fix typo in _function_key
2 parents 34c0255 + 214c17e commit 717d957

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

hypothesis-python/RELEASE.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
RELEASE_TYPE: patch
2+
3+
Fix a typo affecting pretty-printing of lambdas with complex default
4+
arguments.

hypothesis-python/src/hypothesis/internal/lambda_sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _function_key(f, *, bounded_size=False):
8686
if len(consts_repr) > 48:
8787
consts_repr = hashlib.sha384(consts_repr.encode()).digest()
8888
if len(defaults_repr) > 48:
89-
defaults_repr = hashlib.sha384(consts_repr.encode()).digest()
89+
defaults_repr = hashlib.sha384(defaults_repr.encode()).digest()
9090
return (
9191
consts_repr,
9292
defaults_repr,

hypothesis-python/tests/cover/test_reflection.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -752,12 +752,12 @@ def test_is_unrecognized_identity(f):
752752

753753

754754
def test_cache_key_size_is_bounded():
755-
# Modify co_consts because ("a" * 1000) may not be evaluated at compile time
756-
f = lambda: "a"
755+
# Modify co_consts because ("c" * 1000) may not be evaluated at compile time
756+
f = lambda x="a" * 1000, *, y="b" * 1000: "c"
757757
f.__code__ = f.__code__.replace(
758-
co_consts=tuple(c * 1000 if c == "a" else c for c in f.__code__.co_consts)
758+
co_consts=tuple(c * 1000 if c == "c" else c for c in f.__code__.co_consts)
759759
)
760-
assert len(repr(lambda_sources._function_key(f))) > 1000
760+
assert len(repr(lambda_sources._function_key(f))) > 3000
761761
assert len(repr(lambda_sources._function_key(f, bounded_size=True))) < 1000
762762

763763

0 commit comments

Comments
 (0)