MCPcopy
hub / github.com/python-attrs/attrs / test_hash_attribute

Method test_hash_attribute

tests/test_dunders.py:536–548  ·  view source on GitHub ↗

If `hash` is False on an attribute, ignore that attribute.

(self, slots, cache_hash)

Source from the content-addressed store, hash-verified

534
535 @given(booleans(), booleans())
536 def test_hash_attribute(self, slots, cache_hash):
537 """
538 If `hash` is False on an attribute, ignore that attribute.
539 """
540 C = make_class(
541 "C",
542 {"a": attr.ib(hash=False), "b": attr.ib()},
543 slots=slots,
544 unsafe_hash=True,
545 cache_hash=cache_hash,
546 )
547
548 assert hash(C(1, 2)) == hash(C(2, 2))
549
550 @given(booleans())
551 def test_hash_attribute_mirrors_eq(self, eq):

Callers

nothing calls this directly

Calls 2

make_classFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected