TST: Move fully passing tests from test_interval_new to test_interval
State: closed

- [X] tests added / passed
- [X] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`

Some of the `test_interval_new.py` tests are fully passing, so moving them to `test_interval.py` to ensure that new changes don't break them.

Added a couple of TODO's to the new tests related to checking non-monotonic/overlapping/dupe indexes, which generally weren't covered in the new or old tests (with one noted exception).  For the most part existing new/old tests just check the non-overlapping monotonic case.

Made some additional minor modifications to `test_interval_new.py`: cleaned up a couple tests by using `parametrize`, and fixed a few instances of a misplaced parenthesis.

Labels:
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: Interval
description: Interval data type

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19652?src=pr&el=h1) Report
> Merging [#19652](https://codecov.io/gh/pandas-dev/pandas/pull/19652?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/cdfce2b0ad99f7faad57cc5247cf33aab5725bed?src=pr&el=desc) will **decrease** coverage by `0.21%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #19652      +/-   ##
==========================================
- Coverage   91.82%    91.6%   -0.22%     
==========================================
  Files         152      150       -2     
  Lines       49248    48871     -377     
==========================================
- Hits        45222    44769     -453     
- Misses       4026     4102      +76
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.98% <ø> (-0.24%)` | :arrow_down: |
| #single | `41.79% <ø> (-0.1%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/19652?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/tseries/plotting.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvcGxvdHRpbmcucHk=) | `0% <0%> (-100%)` | :arrow_down: |
| [pandas/core/dtypes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Jhc2UucHk=) | `47.61% <0%> (-44.28%)` | :arrow_down: |
| [pandas/plotting/\_compat.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb21wYXQucHk=) | `62% <0%> (-28.91%)` | :arrow_down: |
| [pandas/core/arrays/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2Jhc2UucHk=) | `60% <0%> (-24.15%)` | :arrow_down: |
| [pandas/io/s3.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3MzLnB5) | `72.72% <0%> (-13.64%)` | :arrow_down: |
| [pandas/core/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvbWlzc2luZy5weQ==) | `85.9% <0%> (-5.75%)` | :arrow_down: |
| [pandas/plotting/\_timeseries.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL190aW1lc2VyaWVzLnB5) | `60.82% <0%> (-4.49%)` | :arrow_down: |
| [pandas/core/reshape/tile.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS90aWxlLnB5) | `90.25% <0%> (-3.12%)` | :arrow_down: |
| [pandas/io/html.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2h0bWwucHk=) | `85.98% <0%> (-2.81%)` | :arrow_down: |
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `96.25% <0%> (-2%)` | :arrow_down: |
| ... and [57 more](https://codecov.io/gh/pandas-dev/pandas/pull/19652/diff?src=pr&el=tree-more) | |

------

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

Refactored the `get_loc` tests for scalars and intervals, and added additional cases to test (overlapping, non-monotonic with dupes).  The scalar case is still fully passing.

Haven't split the errors out into separate tests yet; wanted to see if the refactoring makes things better first.  Seems like splitting the errors out would add some bloat, but can do it if that would be preferred.
@jreback : what are your thoughts on the testing approach in the new file I just pushed, `test_interval_specific.py`? Haven't made any changes other than adding this file; didn't want to do too much in case I'm heading down the wrong path.

The idea is to use this approach to test behavior that depends on the underlying structure of the intervals in the index (e.g. overlapping vs. nonoverlapping monotonic), such as `get_loc`, which has specific code paths for different scenarios like this.  Behavior that is independent from the underlying interval structure (e.g. `IntervalIndex.mid`) can be left in the existing `test_interval.py` setting.

Was a little complicated to get all of this set up, but shouldn't be too bad now if someone else wanted to create a new test class variation, e.g. `TestMonotonicDecreasing`.  Not at all tied to the name `test_interval_specific.py` either; could even see this being split off into separate files for each child class, e.g. `test_interval_overlapping.py`.
it’s well documented and pretty clear once u get pass the initial magic

@jorisvandenbossche @TomAugspurger 
Closing this PR for the time being.  Not all that happy with this setup, as it seems a bit over-engineered.  Might try something similar later one once some of the `IntervalIndex` methods and API have been solidified.