Move StrEnum to homeassistant.backports and move Platform to homeassistant.const (#60880)
Co-authored-by: Franck Nijhof <frenck@frenck.nl> Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
3188a364e2
commit
707fe67c00
21 changed files with 59 additions and 86 deletions
|
@ -1,35 +0,0 @@
|
|||
"""Test Home Assistant enum utils."""
|
||||
|
||||
from enum import auto
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.util.enum import StrEnum
|
||||
|
||||
|
||||
def test_strenum():
|
||||
"""Test StrEnum."""
|
||||
|
||||
class TestEnum(StrEnum):
|
||||
Test = "test"
|
||||
|
||||
assert str(TestEnum.Test) == "test"
|
||||
assert TestEnum.Test == "test"
|
||||
assert TestEnum("test") is TestEnum.Test
|
||||
assert TestEnum(TestEnum.Test) is TestEnum.Test
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
TestEnum(42)
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
TestEnum("str but unknown")
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
|
||||
class FailEnum(StrEnum):
|
||||
Test = 42
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
|
||||
class FailEnum2(StrEnum):
|
||||
Test = auto()
|
Loading…
Add table
Add a link
Reference in a new issue