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

Method test_hash_mirrors_eq

tests/test_dunders.py:566–582  ·  view source on GitHub ↗

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

(self, eq)

Source from the content-addressed store, hash-verified

564
565 @given(booleans())
566 def test_hash_mirrors_eq(self, eq):
567 """
568 If `hash` is None, the hash generation mirrors `eq`.
569 """
570 C = make_class("C", {"a": attr.ib()}, eq=eq, frozen=True)
571
572 i = C(1)
573
574 assert i == i
575 assert hash(i) == hash(i)
576
577 if eq:
578 assert C(1) == C(1)
579 assert hash(C(1)) == hash(C(1))
580 else:
581 assert C(1) != C(1)
582 assert hash(C(1)) != hash(C(1))
583
584 @pytest.mark.parametrize(
585 "cls",

Callers

nothing calls this directly

Calls 2

make_classFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected