MCPcopy Index your code
hub / github.com/tortoise/tortoise-orm / test_zoneinfo

Function test_zoneinfo

tests/fields/test_time.py:736–758  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

734
735
736def test_zoneinfo():
737 tz = parse_timezone("Asia/Shanghai")
738 tz2 = parse_timezone("asia/shanghai")
739 tz3 = parse_timezone("asia/ShangHai")
740 now = datetime.now()
741 assert now.replace(tzinfo=tz) == now.replace(tzinfo=tz2) == now.replace(tzinfo=tz3)
742 tz = parse_timezone("US/central")
743 tz2 = parse_timezone("US/Central")
744 assert now.replace(tzinfo=tz) == now.replace(tzinfo=tz2)
745 tz_utc = parse_timezone("UTC")
746 tz_utc2 = parse_timezone("utc")
747 tz_utc3 = parse_timezone("Utc")
748 assert tz_utc.key == tz_utc2.zone == "UTC"
749 assert (
750 now.replace(tzinfo=UTC)
751 == now.replace(tzinfo=tz_utc)
752 == now.replace(tzinfo=tz_utc2)
753 == now.replace(tzinfo=tz_utc3)
754 )
755 with pytest.raises(ZoneInfoNotFoundError):
756 parse_timezone("invalid-zone-name")
757 with pytest.raises(ZoneInfoNotFoundError):
758 parse_timezone("Invalid/Zonename")
759
760
761def test_timezone(tz_env):

Callers

nothing calls this directly

Calls 1

parse_timezoneFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…