Skip to content

TST: Implement maximally-specific/strict fixtures for arithmetic tests #23734

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

Closed
wants to merge 6 commits into from

Conversation

jbrockmendel
Copy link
Member

gets rid of all remaining "FIXME" comments in tests/arithmetic.

Should go after #23681 and #23642 (will need to be rebased)

@pep8speaks
Copy link

Hello @jbrockmendel! Thanks for submitting the PR.

@codecov
Copy link

codecov bot commented Nov 16, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@2c25bd1). Click here to learn what that means.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #23734   +/-   ##
=========================================
  Coverage          ?   92.24%           
=========================================
  Files             ?      161           
  Lines             ?    51403           
  Branches          ?        0           
=========================================
  Hits              ?    47417           
  Misses            ?     3986           
  Partials          ?        0
Flag Coverage Δ
#multiple 90.63% <75%> (?)
#single 42.3% <10%> (?)
Impacted Files Coverage Δ
pandas/util/testing.py 85.68% <75%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c25bd1...9c07638. Read the comment docs.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Looks good! Minor question



@pytest.fixture(params=params)
def box5_and_tz(request):
Copy link
Member

Choose a reason for hiding this comment

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

Do we think this is really needed? (all the timezones) Because with all combinations, you get a quite combinatorial explosion (using this makes a single test into 30 tests)
And if you then further combine it with other fixtures ..

(I don't know how much it is used)

Copy link
Member Author

Choose a reason for hiding this comment

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

combinatorial explosion is an entirely reasonable concern.

Note that this fixture is taking the place of existing usages of box[...], tz_naive_fixture, so the net effect on the number of cases is not as big as it might look at first glance. The big benefit is that tests that previously were either skipped or marked with a # FIXME are now explicitly+strictly xfailed. (some of these can be un-xfailed and simplified if/when the issue behind #23730 is fixed)

More generally the timezone fixtures may be leading to more tests than we really need/want, especially given the overhead of pytest collection. Two thoughts on this I've been mulling over:

  • We've gotten rid of a lot of for-loops and replaced them with parametrization/fixtures. Swinging back in the other direction may be worth considerin. Using the --showlocals flag will cause the pytest error messages to tell us where in the loop an error occurred, obviating one of the disadvantages of looping.

  • Instead of using a fixed set of timezone strings, have a smaller randomized set. We could randomize over the whole space of possible dateutil+pytz+stdlib tzinfos, giving corner cases fewer shadows in which to hide.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, in general those fixtures are certainly good.

There is for example one place where it is combined with the two_hours fixture (6 different ways for timedelta-like), giving 180 tests.

Maybe more specific for this case: are both 'US/Eastern' and 'Asia/Tokyo' needed? (did we had bugs in the past that were related to that?)
And the same for the dateutil ones: did we have bugs in the past in the arithmetics related to having a dateutil timezone?

Copy link
Member Author

Choose a reason for hiding this comment

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

No idea about why tz_naive_fixture includes exactly what it does.

If "the tests are unnecessarily thorough" is the biggest problem we have this week, it's a pretty darn good week.

Copy link
Contributor

Choose a reason for hiding this comment

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

so the timezones that are chosen, have been sources of (since fixed) bugs in the past. We have a pretty good representative sample of various edge cases on timezones and i think we have just about the right amount, not too few and not too many, after all its just 2 per timezone library type + UTC + None.

@jorisvandenbossche jorisvandenbossche added Testing pandas testing functions or related to the test suite Datetime Datetime data dtype labels Nov 16, 2018
@jorisvandenbossche jorisvandenbossche added this to the 0.24.0 milestone Nov 16, 2018
@jbrockmendel
Copy link
Member Author

Travis failures are the segfault and a Hypothesis

@jreback
Copy link
Contributor

jreback commented Nov 17, 2018

can you rebase



@pytest.fixture(params=params)
def box5_and_tz(request):
Copy link
Contributor

Choose a reason for hiding this comment

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

so the timezones that are chosen, have been sources of (since fixed) bugs in the past. We have a pretty good representative sample of various edge cases on timezones and i think we have just about the right amount, not too few and not too many, after all its just 2 per timezone library type + UTC + None.

"""
return request.param


# aliases so we can use the same fixture twice in a test
Copy link
Contributor

Choose a reason for hiding this comment

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

these need self-obvious names

params[n] = param


@pytest.fixture(params=params)
Copy link
Contributor

Choose a reason for hiding this comment

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

so my comment above was fairly general in nature. I don't think you need to test tz's other than [None, 'UTC'] or maybe use 'US/Eastern' rather than UTC to make sure that no times are shifted.

you actually just care if there IS a timezone or not.

@jbrockmendel
Copy link
Member Author

Closing until consensus is reached on #23730.

@jorisvandenbossche
Copy link
Member

Closing until consensus is reached on #23730.

@jbrockmendel How does this depend on that PR? I thought this PR looked OK to almost merge? (some minor comment of Jeff)

@jbrockmendel
Copy link
Member Author

How does this depend on that PR?

This PR papers over a problem which that PR solves. (though granted, that one is going nowhere fast)

@jorisvandenbossche
Copy link
Member

Ah, because here also the transpose versions of the fixtures are included?

@jbrockmendel jbrockmendel deleted the box branch April 5, 2020 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants