TST: Parametrized index tests
State: closed

I came across this module on another change and noticed that a lot of the tests could really use refactoring. There's a ton more to be done with this module but submitting as is so it doesn't get too large.

Can either add other commits on top of this or have this merged (assuming looks OK) and continue down the module in additional PR(s)

Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: Dtype Conversions
description: Unexpected or buggy dtype conversions

Comments:
Hello @WillAyd! Thanks for updating the PR.





Cheers ! There are no PEP8 issues in this Pull Request. :beers: 

##### Comment last updated on April 23, 2018 at 15:49 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20624?src=pr&el=h1) Report
> Merging [#20624](https://codecov.io/gh/pandas-dev/pandas/pull/20624?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/31e77b0b4129134d20cd5027dac0adb9fbd2dca0?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #20624      +/-   ##
==========================================
- Coverage   91.85%   91.82%   -0.03%     
==========================================
  Files         153      153              
  Lines       49310    49310              
==========================================
- Hits        45292    45280      -12     
- Misses       4018     4030      +12
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.21% <ø> (-0.03%)` | :arrow_down: |
| #single | `41.9% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20624?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/20624/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.07% <0%> (-1.74%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20624?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/20624?src=pr&el=footer). Last update [31e77b0...6e46b57](https://codecov.io/gh/pandas-dev/pandas/pull/20624?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Most but not all edits made. I avoided anything that requires moving things out of the module, if only because my suggested plan of attack would be:

 1. Parametrize the existing module where appropriate (this covers ~650 of ~2400 lines, so maybe 3 or 4 more similar PRs)
 2. Replace any class methods / attributes with fixtures where appropriate
 3. Move tests into new modules / sub-modules

Open to suggestions on approach.
@WillAyd can you rebase.

can you expand the nulls this as well? to as much as you can while still having this pass?
Added the suggestions from @jorisvandenbossche with the exception of `np.timedelta64('NaT')` and `np.datetime64('NaT')` as they caused a failure with the below test. 

https://github.com/WillAyd/pandas/blob/6e46b57bc99e70b96eb6de448ab12ff7930a2d10/pandas/tests/indexes/test_base.py#L272

The test is parametrized for a `DatetimeIndex` and a `TimedeltaIndex` and the failure occurs when you try to construct from a list that contains one instance of both (it returns an object-typed Index instead of one or the other). 

I think this is a corner case for this test so we could definitely still add to the fixture and have the test be responsible for skipping where appropriate, but for now I've just kept out of the fixture
thanks @WillAyd 

if you can create an issue for extending the nulls fixture (and issue around that), and an issue about cleaning more testing things (e.g. comments above).