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

Method test_hash_attribute_mirrors_eq

tests/test_dunders.py:551–563  ·  view source on GitHub ↗

If `hash` is None, the hash generation mirrors `eq`.

(self, eq)

Source from the content-addressed store, hash-verified

549
550 @given(booleans())
551 def test_hash_attribute_mirrors_eq(self, eq):
552 """
553 If `hash` is None, the hash generation mirrors `eq`.
554 """
555 C = make_class("C", {"a": attr.ib(eq=eq)}, eq=True, frozen=True)
556
557 if eq:
558 assert C(1) != C(2)
559 assert hash(C(1)) != hash(C(2))
560 assert hash(C(1)) == hash(C(1))
561 else:
562 assert C(1) == C(2)
563 assert hash(C(1)) == hash(C(2))
564
565 @given(booleans())
566 def test_hash_mirrors_eq(self, eq):

Callers

nothing calls this directly

Calls 2

make_classFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected