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 series-tests; replace with fixtures #22550

Closed
20 tasks done
h-vetinari opened this issue Aug 31, 2018 · 8 comments · Fixed by #29220
Closed
20 tasks done

TST/CLN: remove TestData from series-tests; replace with fixtures #22550

h-vetinari opened this issue Aug 31, 2018 · 8 comments · Fixed by #29220
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 31, 2018

This is the sister-issue for Series of #22471 (for frames), where the review in #22236 requested:

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

For Series, this process is started by #22526 by creating a conftest.py that translates all the current attributes of TestData to fixtures, with the following "translation guide":

  • ts -> datetime_series
  • series -> string_series
  • objSeries -> object_series
  • empty -> empty_series

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

Things for follow-ups:

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

An example from #22526 - before:

def test_rename_inplace(self):
    renamer = lambda x: x.strftime('%Y%m%d')
    expected = renamer(self.ts.index[0])
    self.ts.rename(renamer, inplace=True)
    assert self.ts.index[0] == expected

After:

def test_rename_inplace(self, datetime_series):
    renamer = lambda x: x.strftime('%Y%m%d')
    expected = renamer(datetime_series.index[0])
    datetime_series.rename(renamer, inplace=True)
    assert datetime_series.index[0] == expected

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

PS. Note that some fixtures added by #22526 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.

@gfyoung gfyoung added Testing pandas testing functions or related to the test suite Clean labels Sep 1, 2018
@Anjali2019
Copy link
Contributor

Hi! I am looking to start making open source contributions, tests seem like good place to start :)
If no one is working on this, can I take it up?

@h-vetinari
Copy link
Contributor Author

@Anjali2019, sounds great, but you should wait until #22526 has been merged, otherwise the fixtures in conftest.py will not be available for you.

@Anjali2019
Copy link
Contributor

@h-vetinari Sure! makes sense.

@h-vetinari
Copy link
Contributor Author

@Anjali2019 good to go. :)
Probably best to start on a per-module basis.

@Anjali2019
Copy link
Contributor

Awesome! Thanks. Will start on it :D

gfyoung pushed a commit to Anjali2019/pandas that referenced this issue Nov 1, 2018
tm9k1 pushed a commit to tm9k1/pandas that referenced this issue Nov 19, 2018
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
SaturnFromTitan added a commit to SaturnFromTitan/pandas that referenced this issue Oct 19, 2019
* Replaced TestData usage in pandas/tests/series/test_quantile.py with
  datetime_series fixture
SaturnFromTitan added a commit to SaturnFromTitan/pandas that referenced this issue Oct 19, 2019
* Replaced TestData usage in pandas/tests/series/test_rank.py with
  fixture
* Flattened test structure to function-based approach instead of
  class-based approach
SaturnFromTitan added a commit to SaturnFromTitan/pandas that referenced this issue Oct 19, 2019
* Replaced TestData usage in pandas/tests/series/test_rank.py with
  fixture
* Flattened test structure to function-based approach instead of
  class-based approach
SaturnFromTitan added a commit to SaturnFromTitan/pandas that referenced this issue Oct 19, 2019
* Replaced TestData usage in pandas/tests/series/test_rank.py with
  fixture
* Flattened test structure to function-based approach instead of
  class-based approach
@SaturnFromTitan
Copy link
Contributor

SaturnFromTitan commented Oct 22, 2019

test_arithmetic.py also doesn't contain TestData, so after merging my pending PRs we can close this issue ✅

I guess the next step then would be to remove the pandas/tests/series/_common.py altogether

@SaturnFromTitan
Copy link
Contributor

SaturnFromTitan commented Oct 25, 2019

I created the follow-up issue to remove _common.py for series tests. This one here can be closed @simonjayhawkins ✌️

EDIT: I'll first need to remove TestData usage in pandas/tests/series/indexing

@jreback jreback added this to the 1.0 milestone Oct 29, 2019
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
Development

Successfully merging a pull request may close this issue.

5 participants