Skip to content

TST: split up pandas/tests/indexes/test_multi.py #18644

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
jreback opened this issue Dec 5, 2017 · 14 comments · Fixed by #21514
Closed

TST: split up pandas/tests/indexes/test_multi.py #18644

jreback opened this issue Dec 5, 2017 · 14 comments · Fixed by #21514
Labels
good first issue Testing pandas testing functions or related to the test suite
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Dec 5, 2017

getting pretty long, could create a sub-dir and split out into separate files.

@jreback jreback added Difficulty Novice Testing pandas testing functions or related to the test suite labels Dec 5, 2017
@jreback jreback added this to the Next Major Release milestone Dec 5, 2017
@sunilk747
Copy link

Hi @jreback I would like to work on this issue. I am new to this repo, I think this would be a good issue to solve first.

@bhavitvyamalik
Copy link

@jreback I'm interested in working on this issue. Could you please elaborate what exactly has to be done? Thanks!

@jreback
Copy link
Contributor Author

jreback commented Dec 23, 2017

make a sub-dir
pandas/tests/indexes/multi and move tests to files within that dir. we want to split this up into various files by type of tests, look at pandas/tests/indexes/datetimes for example (won't necessarily be the same names), idea is to group tests logically. you won't change any tests just move them (and get the setup/linting only as needed).

should have the same number of tests before and after.

@xchoudhury xchoudhury mentioned this issue Apr 12, 2018
9 tasks
@elmq0022
Copy link
Contributor

elmq0022 commented Jun 5, 2018

@jreback it looks like @xchoudhury is unresponsive or unable to follow up with this item. Is there an appropriate way to step in and help push the work to completion? Thanks!

@xchoudhury
Copy link

@elmq0022 apologies! I got busy with the end of the school year and the start of my internship. If you want, you may completely take over for me. Thanks again!

@jreback
Copy link
Contributor Author

jreback commented Jun 5, 2018

sure - will close this but can take the existing commits and make a new PR

@jreback jreback closed this as completed Jun 5, 2018
@elmq0022
Copy link
Contributor

elmq0022 commented Jun 5, 2018

Thanks @xchoundhury. I've cloned the work you've done so far and will work to incorporate @jreback 's comments from your previous pull request.

@elmq0022
Copy link
Contributor

elmq0022 commented Jun 6, 2018

Hey @jreback. From the description this seems like it would be straight forward, but looking more closely at the code, the task is slightly more involved.

Unfortunately the calls in test_multi.py inherits from the Base object in common.py which has around 60 tests of it's own. If I was to break up multi.py and inherit from Base each time, I would create a mess where a duplicate set of the tests in Base is run for each new file created.

Also, Base is referenced in datetimelike.py, test_base.py, test_category.py, and test_numeric.py besides test_multi.py. So, touching anything in Base class is prohibited.

Here's what I propose:

  1. Remove all the tests defined in test_multi.py from the TestMultiIndex class. This leaves the inherited tests intact.
  2. Create a file of pytest fixture(s) for the MultiIndex specific tests.
  3. Logically group the tests removed in item 1 into separate files using the fixtures created in item 2 as needed.

Please let me know if this approach works for you, or please suggestion modifications.

Thanks!

@WillAyd WillAyd reopened this Jun 6, 2018
@WillAyd
Copy link
Member

WillAyd commented Jun 6, 2018

I would suggest moving the things first that don't require the class hierarchy as it may reveal the easiest way to reveal with the remaining ones. Generally fixtures would be preferable.

@elmq0022
Copy link
Contributor

elmq0022 commented Jun 6, 2018

Thanks @WillAyd. That would be a very good first pass to see how things shake out.

@elmq0022
Copy link
Contributor

I'm making good progress and will probably make a pull request sometime later this week.

elmq0022 added a commit to elmq0022/pandas that referenced this issue Jun 11, 2018
elmq0022 added a commit to elmq0022/pandas that referenced this issue Jun 15, 2018
@elmq0022
Copy link
Contributor

Question:
Where does the data for indices come from in the file pandas/tests/indexes/common.py?

def test_compat(self, indices):
   ...

There when I collect the test suite there are 13 different types of indices generated for the tests like the above. I have been unsuccessful at finding the data or the functions that generate the data for these tests.

My current solution is to pull all the new and overridden functions from test_multi.py and convert them to fixtures while leaving a class test suite that's a mashup of Base and TestMulti to handle the methods that are not overridden in test_multi.py which still pulls in the data.

This way I still end up with the 377 tests in the original test suite for multi indexes and all tests continue to pass.

I am missing something critical here and could use a little push over this speedbump. Thanks!

@WillAyd
Copy link
Member

WillAyd commented Jun 16, 2018

That is a fixture that is defined in conftest.py within that package. Here's the location of it:

def indices(request):

@elmq0022
Copy link
Contributor

elmq0022 commented Jun 16, 2018 via email

elmq0022 added a commit to elmq0022/pandas that referenced this issue Jun 21, 2018
@jreback jreback modified the milestones: Next Major Release, 0.24.0 Jun 22, 2018
elmq0022 added a commit to elmq0022/pandas that referenced this issue Jun 26, 2018
elmq0022 added a commit to elmq0022/pandas that referenced this issue Jun 29, 2018
elmq0022 added a commit to elmq0022/pandas that referenced this issue Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Testing pandas testing functions or related to the test suite
Projects
None yet
6 participants