MCPcopy Create free account
hub / github.com/msgspec/msgspec / test_struct_compare_errors

Method test_struct_compare_errors

tests/unit/test_struct.py:1756–1773  ·  view source on GitHub ↗
(self, op)

Source from the content-addressed store, hash-verified

1754
1755 @pytest.mark.parametrize("op", ["eq", "ne", "le", "lt", "ge", "gt"])
1756 def test_struct_compare_errors(self, op):
1757 func = getattr(operator, op)
1758
1759 class Bad:
1760 def __eq__(self, other):
1761 raise ValueError("Oh no!")
1762
1763 class Test(Struct, order=True):
1764 a: object
1765 b: object
1766
1767 t = Test(1, Bad())
1768 t2 = Test(1, 2)
1769
1770 with pytest.raises(ValueError, match="Oh no!"):
1771 func(t, t2)
1772 with pytest.raises(ValueError, match="Oh no!"):
1773 func(t2, t)
1774
1775
1776class TestTagAndTagField:

Callers

nothing calls this directly

Calls 2

TestClass · 0.70
BadClass · 0.70

Tested by

no test coverage detected