1
0
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:
Ville Skyttä
2025-11-22 16:19:15 +02:00
committed by GitHub
parent ca2e8bfb56
commit 8a2e8d2c61
12 changed files with 53 additions and 68 deletions
+28
View File
@@ -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