def test_enum_value_names_must_be_unique(): with assert_raises(TypeError): enums('a', 'a') with assert_raises(TypeError): enums('a', 'a', 'b')
def test_enums_with_explicit_order(): names = [_make_random_name() for _ in range(3)] v1, v2, v3 = enums(*[(order, name) for order, name in enumerate(names)]) assert v1 < v2 < v3 assert v1 != v2 != v3 and v1 != v3 assert v3 > v2 > v1
def test_enums_with_mixed_ordered_and_unordered_items_is_not_allowed(): with assert_raises(TypeError): enums('a', 'b', (1, 'c'), (2, 'd'))
def test_enums_with_no_order(): names = [_make_random_name() for _ in range(3)] v1, v2, v3 = enums(*names) assert all(isinstance(x, EnumValue) for x in [v1, v2, v3]) assert [str(v1), str(v2), str(v3)] == names assert v1 != v2 != v3 and v1 != v3