CI/TST: Check that unittest.mock is not being used in testing
State: closed

xref https://github.com/pandas-dev/pandas/pull/24624#issuecomment-451658866

Labels:
name: CI
description: Continuous Integration

Comments:
ping on green.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24648?src=pr&el=h1) Report
> Merging [#24648](https://codecov.io/gh/pandas-dev/pandas/pull/24648?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/280a88fdc99d867fbe91ac576184b288bcb49e09?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/24648/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24648?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #24648      +/-   ##
==========================================
- Coverage   92.37%   92.37%   -0.01%     
==========================================
  Files         166      166              
  Lines       52377    52380       +3     
==========================================
+ Hits        48385    48386       +1     
- Misses       3992     3994       +2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.79% <ø> (-0.01%)` | :arrow_down: |
| #single | `43.02% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24648?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/24648/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `97.68% <0%> (-0.16%)` | :arrow_down: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/24648/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `88.09% <0%> (-0.16%)` | :arrow_down: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/24648/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `98.52% <0%> (-0.02%)` | :arrow_down: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/24648/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `98.52% <0%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24648?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/24648?src=pr&el=footer). Last update [280a88f...2c59497](https://codecov.io/gh/pandas-dev/pandas/pull/24648?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/24648?src=pr&el=h1) Report
> Merging [#24648](https://codecov.io/gh/pandas-dev/pandas/pull/24648?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/280a88fdc99d867fbe91ac576184b288bcb49e09?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/24648/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24648?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #24648      +/-   ##
==========================================
- Coverage   92.37%   92.37%   -0.01%     
==========================================
  Files         166      166              
  Lines       52377    52380       +3     
==========================================
+ Hits        48385    48386       +1     
- Misses       3992     3994       +2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.79% <ø> (-0.01%)` | :arrow_down: |
| #single | `43.02% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24648?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/24648/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `97.68% <0%> (-0.16%)` | :arrow_down: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/24648/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `88.09% <0%> (-0.16%)` | :arrow_down: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/24648/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `98.52% <0%> (-0.02%)` | :arrow_down: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/24648/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `98.52% <0%> (ø)` | :arrow_up: |

------

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

thanks!
What was the rationale behind this? `unittest.mock.Mock` and `unittest.mock.MagicMock` are really useful (see [this](https://github.com/pandas-dev/pandas/commit/ced8628a71063cf4b080ef335cd7c005d7b4f8b7#diff-86951d150476847d783821ee0f0842d7) for example), and there's no equivalent with the `monkeypatch` fixture (which really only substitutes `unittest.mock.patch`, not the whole `unittest.mock` module). 

If this was to avoid the import under Python 2, it's no longer relevant since Python 2 is no longer supported, and it should be reverted.

CC @simonjayhawkins, @jreback, @WillAyd 
i think the description says it all

there is really no reason to use mock as monkey patch will do the limited things that we need

generally we prefer to not mock at all - when apis change often time mocks will work but the code is broken