mirror of
https://github.com/home-assistant/core.git
synced 2026-05-08 09:38:58 +01:00
Add internal util.snakecase, use instead of stringcase (#156775)
Co-authored-by: Franck Nijhof <git@frenck.dev> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -233,3 +233,31 @@ async def test_throttle_async() -> None:
|
||||
|
||||
assert (await test_method2()) is True
|
||||
assert (await test_method2()) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("input", "expected"),
|
||||
[
|
||||
("fooBar", "foo_bar"),
|
||||
("FooBar", "foo_bar"),
|
||||
("Foobar", "foobar"),
|
||||
("Foo.bar", "foo_bar"),
|
||||
("_foo-Bar", "_foo_bar"),
|
||||
("HTTP", "http"),
|
||||
("HTTPResponse", "http_response"),
|
||||
("iPhone", "i_phone"),
|
||||
("IPAddress", "ip_address"),
|
||||
("IP_Address", "ip_address"),
|
||||
("My IP Address", "my_ip_address"),
|
||||
("LocalIP", "local_ip"),
|
||||
("Python3Thing", "python3_thing"),
|
||||
("mTLS", "m_tls"),
|
||||
("DTrace", "dtrace"),
|
||||
("IPv4", "ipv4"),
|
||||
("ID", "id"),
|
||||
("", ""),
|
||||
],
|
||||
)
|
||||
def test_snakecase(input, expected) -> None:
|
||||
"""Test snake casing a string."""
|
||||
assert util.snakecase(input) == expected
|
||||
|
||||
Reference in New Issue
Block a user