Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/annotations/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,3 +984,17 @@ def _generate_next_value_(name, start, count, last_values) -> str:
self.assertEqual(ColorAutoOverride.ONE.spanish, "Uno")
self.assertEqual(ColorAutoOverride.TWO.spanish, "Dos")
self.assertEqual(ColorAutoOverride.THREE.spanish, "Tres")

def test_name_annotation_plain_non_symmetric(self):
"""Annotating 'name' without Symmetric is silently ignored (line 630->644)."""

class MyEnum(EnumProperties):
name: str # plain (non-symmetric) — hits the issubclass(prop, _SProp) False branch
label: str

A = "a", "alpha"
B = "b", "beta"

# 'name' behavior is unchanged: still case-sensitive symmetric by default
self.assertIs(MyEnum("A"), MyEnum.A)
self.assertEqual(MyEnum.A.label, "alpha")
5 changes: 5 additions & 0 deletions tests/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ def test_names_as_empty_list(self):
AnEnum = EnumProperties("AnEnum", [], properties=("label",))
self.assertEqual(list(AnEnum), [])

def test_names_as_empty_generator(self):
"""Empty generator produces an enum with no members."""
AnEnum = EnumProperties("AnEnum", (x for x in []), properties=("label",))
self.assertEqual(list(AnEnum), [])

def test_names_as_plain_list_of_strings(self):
"""List of plain strings auto-assigns sequential start values (line 508)."""
AnEnum = EnumProperties("AnEnum", ["X", "Y", "Z"], start=10)
Expand Down
Loading