Skip to content

TST: parameterize more tests #45131

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 6 commits into from
Dec 31, 2021
Merged

Conversation

mroeschke
Copy link
Member

  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Dec 30, 2021
@mroeschke mroeschke added this to the 1.4 milestone Dec 30, 2021
@jreback
Copy link
Contributor

jreback commented Dec 30, 2021

@jbrockmendel if you can have a quick glance here

@@ -1810,55 +1810,50 @@ def test_dt64ser_sub_datetime_dtype(self):
# TODO: This next block of tests came from tests.series.test_operators,
# needs to be de-duplicated and parametrized over `box` classes

def test_operators_datetimelike_invalid(self, all_arithmetic_operators):
# these are all TypeEror ops
@pytest.mark.parametrize(
Copy link
Member

Choose a reason for hiding this comment

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

I dont think this improves the clarity of this test. id suggest something like:

def test_whatever(all_arithmetic_operators):
    op_str = all_arithmetic_operators
    if op_str in [add, sub, radd, rsub]:
        return # or skip, or use a different fixture; these are tested elsewhere

    tdser = [timedelta(minutes=5, seconds=3), NaT, timedelta(minutes=5, seconds=3)]
    dt64ser = [Timestamp("20111230"), Timestamp("20120101"), NaT]
    dt64tz_ser = ...

    for iter_over_pairs([tdser, dt64ser, dt64tz_ser]):
         with pytest.raises...
               op(whatever)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm at least with this version an error with any of the dtlike-ser won't prevent the other dtlike-ser from being tested due to the parameterize

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough. I might be overly-wary of over-parametrizing in the arithmetic tests since there's a ton of them

Copy link
Member Author

Choose a reason for hiding this comment

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

Hopefully with a second pass we can remove the need for this test entirely.

@jbrockmendel
Copy link
Member

comments on a few, the rest look good

@@ -58,6 +58,17 @@ def adjust_negative_zero(zero, expected):
return expected


def compare_op(series, other, op):
Copy link
Contributor

Choose a reason for hiding this comment

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

something like this you might want o make a first class assert_* function (but ok for now)

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.

thanks @mroeschke pls followup as needed

@jreback jreback merged commit 3c6a26e into pandas-dev:master Dec 31, 2021
@mroeschke mroeschke deleted the ref/parameterize2 branch December 31, 2021 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants