()
| 73 | |
| 74 | |
| 75 | def 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 | |
| 109 | def test_pickle_identity_preserved(): |
nothing calls this directly
no test coverage detected