Reputation: 428
I have the following error which happens only in CI:
ValueError: time data '09.30.2019 17:50 EDT' does not match format '%m.%d.%Y %H:%M %Z'
Here's my test:
def test_extract_time_from_page(pjm_html):
expected_time = datetime.strptime("09.30.2019 17:50 EDT", "%m.%d.%Y %H:%M %Z")
res = demand.extract_time_from_page(pjm_html)
assert res == expected_time
It passes locally. I'm not sure how this could be different running in a CI environment
Edit: I can reproduce this by changing my machine timezone to something other than EDT. Can you not use a timezone different than your current timezone with datetime.strptime
?
Upvotes: 2
Views: 55
Reputation: 15120
This is a known issue with the %Z
directive. The current documentation is confusing and there is a pending request to have the documentation revised. The pending documentation change explains the issue you are experiencing:
Note that
strptime
only accepts certain values for%Z
:UTC
andGMT
, and what is defined intime.tzname
for your own locales. It will return aValueError
for any invalid strings. For example, someone living in Japan will haveUTC
,GMT
andJST
as valid values, but probably notEST
.
Upvotes: 2
Reputation: 4366
Might be a problem with pytz lib. Compare pytz libs on your CI worker and locally. Here you can find an explanation which points to wikipedia list of timezones which says that EDT is a deprecated timezone. You can try updating your pytz lib on CI worker.
Upvotes: 0