Skip to content

Commit

Permalink
Add unit test for alias colliding with name of same entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Oct 31, 2023
1 parent 4c061ee commit dccd322
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_classes_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,19 @@ class Temperature(Sensor):
assert Sensor["oxygen"] == Sensor["o2"] == Sensor["air"] == Oxygen


def test_aliases_list_self_collision():
"""Having an alias be the same as ``name`` should NOT generate a KeyCollisionError."""

class Sensor(Registry):
pass

class Oxygen(Sensor, aliases=["oxygen"]):
pass

assert list(Sensor.keys()) == ["oxygen"]
assert Sensor["oxygen"] == Oxygen


def test_aliases_single_str_invalid():
class Sensor(Registry):
pass
Expand Down

0 comments on commit dccd322

Please sign in to comment.