Skip to content
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

TST/CLN: remove TestData from frame-tests; replace with fixtures #22471

Closed
16 of 34 tasks
h-vetinari opened this issue Aug 22, 2018 · 5 comments · Fixed by #29226
Closed
16 of 34 tasks

TST/CLN: remove TestData from frame-tests; replace with fixtures #22471

h-vetinari opened this issue Aug 22, 2018 · 5 comments · Fixed by #29226
Labels
Clean good first issue Testing pandas testing functions or related to the test suite
Milestone

Comments

@h-vetinari
Copy link
Contributor

h-vetinari commented Aug 22, 2018

Following review in #22236:

ok, pls open a new issue that refs this, to remove use of TestData in favor of fixtures

Started the process in that PR by creating a conftest.py that translates all the current attributes of TestData to fixtures, with the following "translation guide":

  • frame -> float_frame
  • frame2 -> float_frame2
  • intframe -> int_frame
  • tsframe -> datetime_frame
  • mixed_frame -> float_string_frame
  • mixed_float -> mixed_float_frame
  • mixed_float2 -> mixed_float_frame2
  • mixed_int -> mixed_int_frame
  • all_mixed -> mixed_type_frame
  • tzframe -> timezone_frame
  • empty -> empty_frame
  • ts1 -> datetime_series
  • ts2 -> datetime_series_short
  • simple -> simple_frame

Need to incrementally replace their usages in pandas/tests/frame/ (example below).

Things for follow-ups:

  • Remove other class-based test-methods
  • Turn tests from class- to function-based

An example from #22236 - before:

def test_set_columns(self):
    cols = Index(np.arange(len(self.mixed_frame.columns)))
    self.mixed_frame.columns = cols
    with tm.assert_raises_regex(ValueError, 'Length mismatch'):
        self.mixed_frame.columns = cols[::2]

After:

def test_set_columns(self, float_string_frame):
    cols = Index(np.arange(len(float_string_frame.columns)))
    float_string_frame.columns = cols
    with tm.assert_raises_regex(ValueError, 'Length mismatch'):
        float_string_frame.columns = cols[::2]

Basically, it comes down to replacing all the occurrences of self.<name> with translation_guide[<name>] (and specifying<name> as a parameter to the function).

PS. Note that some fixtures added by #22236 have now been removed by #24885. Please check #24885 which code was removed, in case you should need it for the fixturisation. Alternatively, you can ping me, @jbrockmendel or @jreback.

@h-vetinari
Copy link
Contributor Author

@gfyoung
I think this issue and #22550 should have a "good first issue" and potentially "difficulty: novice" tag. What do you think?

@gfyoung
Copy link
Member

gfyoung commented Sep 16, 2018

@h-vetinari : Seems reasonable to me. Done.

@akulagrawal
Copy link

Hi! I am a beginner to open source. Can I take up this issue?

@gfyoung
Copy link
Member

gfyoung commented Oct 1, 2018

@akulagrawal : Go for it!

@SaturnFromTitan
Copy link
Contributor

Seems like the following files don't contain TestData (anymore) and can be checked or removed from the issue description:

  • test_constructors.py
  • test_dtypes.py
  • test_period.py
  • test_quantile.py
  • test_rank.py
  • test_sort_values_level_as_str.py
  • test_timezones.py
  • test_validate.py

I'll take a look at the others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean good first issue Testing pandas testing functions or related to the test suite
Projects
None yet
5 participants