MCPcopy
hub / github.com/pex-tool/pex / test_comparable

Function test_comparable

tests/test_enum.py:75–106  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73
74
75def test_comparable():
76 # type: () -> None
77
78 assert Color.BLUE > Color.RED
79 assert Color.GREEN >= Color.RED
80 assert Color.RED >= Color.RED
81 assert Color.RED <= Color.RED
82 assert Color.RED < Color.GREEN
83
84 assert [Color.RED, Color.GREEN, Color.BLUE] == sorted(Color.values())
85 assert [Color.RED, Color.GREEN, Color.BLUE] == sorted([Color.GREEN, Color.RED, Color.BLUE])
86
87 class Op(Enum["Op.Value"]):
88 class Value(Enum.Value):
89 pass
90
91 ADD = Value("+")
92 SUB = Value("-")
93
94 Op.seal()
95
96 with pytest.raises(
97 TypeError,
98 match=re.escape(
99 "Can only compare values of type {op_value_type} amongst themselves; given 'red' of "
100 "type {color_value_type}.".format(
101 op_value_type=qualified_name(Op.Value),
102 color_value_type=qualified_name(Color.Value),
103 )
104 ),
105 ):
106 assert Op.SUB > Color.RED
107
108
109def test_pickle_identity_preserved():

Callers

nothing calls this directly

Calls 3

qualified_nameFunction · 0.90
sealMethod · 0.80
valuesMethod · 0.45

Tested by

no test coverage detected