Skip to content

BUG: pytz.AmbiguousTimeError not caught in hypothesis test test_on_offset_implementations (GH41906) #41907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 16, 2021

Conversation

jackzyliu
Copy link
Contributor

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment otherwise LGTM

@mroeschke mroeschke added Frequency DateOffsets Testing pandas testing functions or related to the test suite labels Jun 9, 2021
@jackzyliu jackzyliu force-pushed the debug_africa_kinshasa_tz branch from f97e9a4 to d914467 Compare June 9, 2021 19:46
@jreback
Copy link
Contributor

jreback commented Jun 10, 2021

is it possible to add the offending test case?

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible add the offending test case as well?

@jackzyliu
Copy link
Contributor Author

is it possible to add the offending test case?

Sure, any preference between 1) a separate test with assertRaises and 2) just an @example(dt, offset) to make sure the case is always tested?

@jreback
Copy link
Contributor

jreback commented Jun 11, 2021

prefer 1

def test_nontick_offset_with_ambiguous_time_error(case):
# .apply for non-Tick offsets throws AmbiguousTimeError when the target dt
# is dst-ambiguous
original_dt, target_dt, offset, tz = case
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make these parameterized arguments instead? i.e.

def test_nontick_offset_with_ambiguous_time_error(original_dt, target_dt, offset, tz):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem

@jackzyliu jackzyliu force-pushed the debug_africa_kinshasa_tz branch from ff590be to fedb49e Compare June 11, 2021 20:20
@jackzyliu
Copy link
Contributor Author

@jreback @mroeschke

I took at a quick look at the failing Africa/Kinshasa test case (also the original offending test case) under actions-37-minimum_versions.yaml. As expected, pytz=2017.3 does not yet contain the DST information for Africa/Kinshasa that triggers AmbiguoutTimeError - namely datetime.datetime(1905, 6, 30, 23, 46, 25),.

python=3.8 pytz=2020.1:

In[6]: import pytz
In[7]: pytz.__version__
Out[7]: '2021.1'
In[8]: pytz.timezone('Africa/Kinshasa')._utc_transition_times
Out[8]: 
[datetime.datetime(1, 1, 1, 0, 0),
 datetime.datetime(1905, 6, 30, 23, 46, 25),      # ----> triggering transition time
 datetime.datetime(1908, 7, 1, 0, 0),
 datetime.datetime(1913, 12, 31, 23, 46, 25),
 datetime.datetime(1919, 8, 31, 23, 30)]

python=3.7 pytz=2017.3:

>>> import pytz
>>> pytz.__version__
'2017.3'
>>> pytz.timezone('Africa/Kinshasa')._utc_transition_times
[datetime.datetime(1, 1, 1, 0, 0), datetime.datetime(1919, 8, 31, 23, 46, 24)]

Are you okay with removing this original offending test case in test_nontick_offset_with_ambiguous_time_error?

@jreback jreback added this to the 1.4 milestone Jun 15, 2021
@jreback
Copy link
Contributor

jreback commented Jun 15, 2021

@jackzyliu yeah go ahead and skip for py37 (going to merge this to 1.4 which is going to have 3.7 removed anyhow), so just xfail for rn.

@jackzyliu jackzyliu force-pushed the debug_africa_kinshasa_tz branch from fedb49e to 25f1368 Compare June 15, 2021 01:29
@jackzyliu
Copy link
Contributor Author

@jreback Got it! Just updated it accordingly and rebased after master.

@jreback jreback merged commit 7dbac8d into pandas-dev:master Jun 16, 2021
@jreback
Copy link
Contributor

jreback commented Jun 16, 2021

thanks @jackzyliu

iynehz pushed a commit to iynehz/pandas that referenced this pull request Jun 20, 2021
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frequency DateOffsets Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: pytz.AmbiguousTimeError not caught in hypothesis test_on_offset_implementations
3 participants