Closed When-No-Light closed 11 months ago
get_localzone()
returns a timezone object, so the name in the file has to be valid, or it can't return.
ZoneInfoNotFoundError
is the correct and expected behavior when you have configured a timezone that isn't valid.
In my tests I use pyfakefs.fake_filesystem_unittest to mock system files, and I found that in case when I have mocked "/etc/timezone" and real "/usr/share/zoneinfo" files, function get_localzone() return string from "/etc/timezone". It could be invalid TZ, something like "Incorrect/TZ" or "123". But when you use reload_localzone() it raises ZoneInfoNotFoundError exception, get_localzone() return object that don't has "key" attr.
I had this problem on Ubuntu 23.04 and tzlocal==5.0.1