TST: remove patches to pandas.util.testing.N
State: closed

xref https://github.com/pandas-dev/pandas/pull/24769#issuecomment-455326819

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

Comments:
Another solution might be to add this as a keyword argument to those functions, so the monkeypatch is not needed?
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24826?src=pr&el=h1) Report
> Merging [#24826](https://codecov.io/gh/pandas-dev/pandas/pull/24826?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/512830b46e678a1c6bd86cc60f54d74ff75792db?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/24826/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24826?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #24826   +/-   ##
=======================================
  Coverage   92.38%   92.38%           
=======================================
  Files         166      166           
  Lines       52379    52379           
=======================================
  Hits        48392    48392           
  Misses       3987     3987
```

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


------

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

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

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

```diff
@@            Coverage Diff             @@
##           master   #24826      +/-   ##
==========================================
- Coverage   92.38%   92.38%   -0.01%     
==========================================
  Files         166      166              
  Lines       52379    52379              
==========================================
- Hits        48392    48391       -1     
- Misses       3987     3988       +1
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24826?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24826/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.04% <0%> (-0.1%)` | :arrow_down: |

------

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

@jorisvandenbossche 

> so the monkeypatch is not needed?

are you not a fan of monkeypatch?

there are only 4 instances where the patch is needed, one of those is for depecated Panel another instance is code duplication resulting from some tests using unittest setup method and other tests having the setup method converted to pytest fixtures.

the monkeypatch used as context manager is to make it more explicit what is happening and ensuring that the patch in the fixture is undone before the test executes. this may appear to add additional lines of code.

my only concern with altering pandas.util.testing is that it is in the pandas directory and not the tests directory, so a change here would be considered an api change?
looks ok, ping on green.
@jreback green!
Thanks @simonjayhawkins