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

- [x] closes #18644
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

The file is split out, the number of tests remains 377 (2 skips on my machine; all other test cases pass), the code uses fixtures in all instances, new fixtures are in a local conftest.py file, and there are no dependencies on classes.  

I'm happy to receive and address any feedback.  

Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: MultiIndex

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21514?src=pr&el=h1) Report
> Merging [#21514](https://codecov.io/gh/pandas-dev/pandas/pull/21514?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/8f322149ebd2a30f2f2d48c06863cd783166fa84?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/21514/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/21514?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #21514   +/-   ##
=======================================
  Coverage   91.92%   91.92%           
=======================================
  Files         158      158           
  Lines       49703    49703           
=======================================
  Hits        45689    45689           
  Misses       4014     4014
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.3% <ø> (ø)` | :arrow_up: |
| #single | `41.99% <ø> (ø)` | :arrow_up: |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21514?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/21514?src=pr&el=footer). Last update [8f32214...baaace3](https://codecov.io/gh/pandas-dev/pandas/pull/21514?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

@jreback thank you for the quick feedback.  I will make updates over the next day or two.  
So, someone removed the get_data_path from the pandas.utils.testing.  I forgot to run pytest after I rebased.  I can inline the function if need be.  

The bigger issue is the rebase broke my ability to run pytest even on master.   Any thoughts on how to deal with the below?

```
Traceback (most recent call last):
  File "/home/zero/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config.py", line 334, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/home/zero/pandas/pandas/tests/indexes/test_multi.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/zero/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config.py", line 334, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/home/zero/pandas/pandas/tests/indexes')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):  File "/home/zero/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config.py", line 365, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/home/zero/pandas/pandas/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/zero/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/_pytest/config.py", line 371, in _importconftest
    mod = conftestpath.pyimport()
  File "/home/zero/anaconda3/envs/pandas-dev/lib/python3.6/site-packages/py/_path/local.py", line 668, in pyimport
    __import__(modname)
  File "/home/zero/pandas/pandas/__init__.py", line 42, in <module>
    from pandas.core.api import *
  File "/home/zero/pandas/pandas/core/api.py", line 10, in <module>
    from pandas.core.groupby.groupby import Grouper
  File "/home/zero/pandas/pandas/core/groupby/__init__.py", line 2, in <module>
    from pandas.core.groupby.groupby import (
  File "/home/zero/pandas/pandas/core/groupby/groupby.py", line 46, in <module>
    from pandas.core.index import (Index, MultiIndex,
  File "/home/zero/pandas/pandas/core/index.py", line 2, in <module>
    from pandas.core.indexes.api import *
  File "/home/zero/pandas/pandas/core/indexes/api.py", line 4, in <module>
    from pandas.core.indexes.base import (Index,
  File "/home/zero/pandas/pandas/core/indexes/base.py", line 7, in <module>
    from pandas._libs import (lib, index as libindex, tslib as libts,
  File "pandas/_libs/index.pyx", line 28, in init pandas._libs.index
    from pandas._libs.tslibs import period as periodlib
  File "pandas/_libs/tslibs/period.pyx", line 59, in init pandas._libs.tslibs.period
  File "/home/zero/pandas/pandas/tseries/offsets.py", line 2327, in <module>
    offset=BDay(), time_rule=None):
  File "/home/zero/pandas/pandas/tseries/offsets.py", line 484, in __init__
    BaseOffset.__init__(self, n, normalize)
TypeError: object.__init__() takes no parameters
ERROR: could not load /home/zero/pandas/pandas/conftest.py
```


You need to rebuild the Cython extensions after pulling from master as there have been recent changes with those
Will do thanks!

On Tue, Jun 26, 2018 at 12:52 PM, William Ayd <notifications@github.com>
wrote:

> You need to rebuild the Cython extensions after pulling from master as
> there have been recent changes with those
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/21514#issuecomment-400405575>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ADSn4F5qlxelBvmPjD6W-vs43sPeqq8Iks5uAnTkgaJpZM4Uq6xt>
> .
>

I think the datapath fixture is a step backward from the get_data_path which was relative to the test directory.  I can't run pytest from the directly from the tests/indexes/mulit directory successfully anymore.  I now have to run it from the root directory if I want the test to pass.  This should probably be relative to the director of the test like before. 
> I think the datapath fixture is a step backward from the get_data_path which was relative to the test directory. I can't run pytest from the directly from the tests/indexes/mulit directory successfully anymore. I now have to run it from the root directory if I want the test to pass. This should probably be relative to the director of the test like before.

hmm. I almost *always* run at the root directory. but I suppose this could be addressed as well. can you open a separate issue for this?

cc @TomAugspurger 
How does pytest handle fixtures when you don't run from the root of the tests dir?
I don't think it is necessarily a pytest issue.  An absolute path would
just be better since it makes the working directory  irrelevant.  Something
like os.path.dir(__file__) to resolve this would be relatively straight
forward.

On Tue, Jun 26, 2018, 2:18 PM Tom Augspurger <notifications@github.com>
wrote:

> How does pytest handle fixtures when you don't run from the root of the
> tests dir?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/21514#issuecomment-400431297>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ADSn4OBcTwxX3X8AMs7wiAADqPtZdpeGks5uAokIgaJpZM4Uq6xt>
> .
>

We need a fixture so that these tests are skipped / failed (depending on
the config option) when the file isn't present.

What exception do you get?



On Tue, Jun 26, 2018 at 2:38 PM, LeakedMemory <notifications@github.com>
wrote:

> I don't think it is necessarily a pytest issue. An absolute path would
> just be better since it makes the working directory irrelevant. Something
> like os.path.dir(__file__) to resolve this would be relatively straight
> forward.
>
> On Tue, Jun 26, 2018, 2:18 PM Tom Augspurger <notifications@github.com>
> wrote:
>
> > How does pytest handle fixtures when you don't run from the root of the
> > tests dir?
> >
> > —
> > You are receiving this because you authored the thread.
> > Reply to this email directly, view it on GitHub
> > <https://github.com/pandas-dev/pandas/pull/21514#issuecomment-400431297
> >,
> > or mute the thread
> > <https://github.com/notifications/unsubscribe-auth/
> ADSn4OBcTwxX3X8AMs7wiAADqPtZdpeGks5uAokIgaJpZM4Uq6xt>
> > .
>
> >
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/21514#issuecomment-400436956>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIgH1RRF_RYFFOQHTzMMM__rMXUEbks5uAo2qgaJpZM4Uq6xt>
> .
>

I will try to get to the last round of comments later this week.  I pushed some fixes prior to seeing the comments.  
@TomAugspurger  I see where you're going with the fixture.  The approach definitely makes sense, but I just like that absolute file paths let me run code regardless of where I am on the command line.  I opened an issue, #21646, and submitted a pull request to address it.  Thanks.
thanks @elmq0022 ping when you want me to look.
@jreback looks like everything is green.  I believe all the comments are addressed.  I also included the last updates to test_multi.py in test unique and duplicates.  
@jreback it looks like there were a couple of tests added that I need to include and rebase.  Do you have any additional feedback.  I would like to get this merged as soon as possible so everything can stay in sync.  Thanks!
yes I agree. pls rebase. ping as soon as green and can merge. 
@jreback I just pushed the rebased code.  Will check back in a half hour or so to see if everything is green.  Thanks!
great thanks! I will go thru and  possibly make some comments. but take them as for a followup.
thanks @elmq0022 very very nice! great job!

if you can do a followup to address comments (and some TODO's you had in the code would be much appreciated)