Skip to content

TST: parametrize test_info #37887

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 11 commits into from
Nov 25, 2020
Merged

Conversation

ivanovmg
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Precursor for #37320

  • Parametrize tests
  • Rename some of test functions

@ivanovmg ivanovmg requested review from MarcoGorelli and jreback and removed request for jreback November 16, 2020 07:59
@@ -82,18 +78,41 @@ def test_info_categorical_column():
df2.info(buf=buf)


def test_info(float_frame, datetime_frame):
def test_info_frame_float_frame_just_works(float_frame):
Copy link
Member

Choose a reason for hiding this comment

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

"just_works" -> "smoke_test" maybe?

the existing test is a pattern i really dislike, where we have two unrelated fixtures for what should be separate tests (that you've separated, which i like). but it would be nice to find a way to parametrize over float_frame/datetime_frame. i think indirect might be related, but never fully got the hang of that

Copy link
Member Author

Choose a reason for hiding this comment

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

I managed to do so using the approach described here: https://stackoverflow.com/a/64246323
For that, however, I needed to explicitly import float_frame. Without the import it would not work.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now pre-commit check complains about the non-standard imports because I explicitly import fixture functions.
Please suggest

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed that as @jreback suggested #37887 (comment)

),
],
)
def test_info_memory_usage_qualified(frame, plus):
Copy link
Member

Choose a reason for hiding this comment

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

separating these i like, but im trying to push back against parametrization that creates DataFrame etc objects at test collection time. it increases the memory footprint which is breaking the windows builds.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I remember your suggestion to reduce footprint.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverted back.

@jreback jreback added the Testing pandas testing functions or related to the test suite label Nov 17, 2020
io = StringIO()
float_frame.info(buf=io)
datetime_frame.info(buf=io)
frame.info(buf=io)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you do result = io.getvalue() and assert somthing about the result (not the whole thing)

Copy link
Contributor

Choose a reason for hiding this comment

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

e.g. assert len(result.splitlines()) > 100 or something

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

@ivanovmg
Copy link
Member Author

Can anyone suggest on dealing with pre-commit check?
It complains that I used non-standard imports. In particular I imported fixtures from pandas/conftest.py.
Without this import the parametrization I used will not work (import error).
@jreback @jbrockmendel

@jbrockmendel
Copy link
Member

I think we need to abandon the idea of using the indirect fixture parametrization

@ivanovmg
Copy link
Member Author

I think we need to abandon the idea of using the indirect fixture parametrization

So I should go ahead and split test_info_smoke_test into four different test functions (for int_frame, float_frame, datatime_frame and duplicate_columns_frame)? Much like it was there before.

@jbrockmendel
Copy link
Member

bottom line i dont think this is worth futzing over all that much. if you really want, you could try something like

@pytest.mark.parametrize("tmfunc", [tm.getSeriesData, tm.getTimeSeriesData, lambda: tm.getSeriesData()).astype("int64"),  duplicate_columns_frame]
def test_thing(tmfunc):
    frame = DataFrame(tmfunc())
    [...]

@ivanovmg ivanovmg requested a review from jreback November 22, 2020 15:16
@ivanovmg
Copy link
Member Author

It's greenish.

Copy link
Member

@jbrockmendel jbrockmendel left a comment

Choose a reason for hiding this comment

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

LGTM

@jreback jreback added the Output-Formatting __repr__ of pandas objects, to_string label Nov 25, 2020
@jreback jreback added this to the 1.2 milestone Nov 25, 2020
@jreback jreback merged commit 03b9ad8 into pandas-dev:master Nov 25, 2020
@jreback
Copy link
Contributor

jreback commented Nov 25, 2020

thanks @ivanovmg

@ivanovmg ivanovmg deleted the refactor/test-info branch December 3, 2020 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string 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