Skip to content

Commit e306a99

Browse files
committed
Ensure coverage of bounded_size branch
1 parent 0cec064 commit e306a99

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

hypothesis-python/tests/cover/test_reflection.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,16 @@ def test_is_unrecognized_identity(f):
752752
assert not is_identity_function(f)
753753

754754

755+
def test_cache_key_size_is_bounded():
756+
# Modify co_consts because ("a" * 1000) may not be evaluated at compile time
757+
f = lambda: "a"
758+
f.__code__ = f.__code__.replace(
759+
co_consts=tuple(c*1000 if c=="a" else c for c in f.__code__.co_consts)
760+
)
761+
assert len(repr(reflection._lambda_source_key(f))) > 1000
762+
assert len(repr(reflection._lambda_source_key(f, bounded_size=True))) < 1000
763+
764+
755765
def test_lambda_source_key_distinguishes_alpha_renames():
756766
# these terms are equivalent under the lambda calculus, but their
757767
# representations are not, so they should be cached differently.

0 commit comments

Comments
 (0)