MCPcopy Create free account
hub / github.com/apache/tvm-ffi / test_payload_enum_compat_behaviors

Function test_payload_enum_compat_behaviors

tests/python/test_dataclass_enum.py:177–202  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

175
176
177def test_payload_enum_compat_behaviors() -> None:
178 class Priority(IntEnum, type_key=_unique_key("IntEnumCompat")):
179 low = 10
180 high = 20
181
182 class Opcode(StrEnum, type_key=_unique_key("StrEnumCompat")):
183 add = "+"
184 mul = "*"
185
186 assert Priority.low.name == "low" # ty: ignore[possibly-missing-attribute]
187 assert repr(Priority.low) == "Priority.low"
188 assert Priority.low == 10
189 assert Priority.low != 20
190 assert str(Priority.low) == "10"
191 assert hash(Priority.low) == hash(10)
192 assert Priority(10).same_as(Priority.low) # ty: ignore[missing-argument]
193 assert Priority("low").same_as(Priority.low) # ty: ignore[missing-argument, invalid-argument-type]
194
195 assert Opcode.add.name == "add" # ty: ignore[possibly-missing-attribute]
196 assert repr(Opcode.add) == "Opcode.add"
197 assert Opcode.add == "+"
198 assert Opcode.add != "*"
199 assert str(Opcode.add) == "+"
200 assert hash(Opcode.add) == hash("+")
201 assert Opcode("+").same_as(Opcode.add) # ty: ignore[missing-argument, invalid-argument-type]
202 assert Opcode("add").same_as(Opcode.add) # ty: ignore[missing-argument, invalid-argument-type]
203
204
205def test_payload_literal_sugar_preserves_annotated_field_defaults() -> None:

Callers

nothing calls this directly

Calls 5

reprClass · 0.85
hashClass · 0.85
PriorityClass · 0.70
OpcodeClass · 0.70
same_asMethod · 0.45

Tested by

no test coverage detected