REF/TST: Add more pytest idiom to resample/test_base.py
State: closed

- [ n/a] xref #17806
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ n/a] whatsnew entry

in this pass:

- alternative approach to #24324
- parametrize base class tests individually to avoid changing fixtures

cc @jreback 

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

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





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

##### Comment last updated on December 23, 2018 at 19:07 Hours UTC
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24377?src=pr&el=h1) Report
> Merging [#24377](https://codecov.io/gh/pandas-dev/pandas/pull/24377?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/5d134ec1a9ab118abbd16157bd161783547117e6?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/24377/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/24377?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #24377   +/-   ##
=======================================
  Coverage   92.29%   92.29%           
=======================================
  Files         162      162           
  Lines       51841    51841           
=======================================
  Hits        47847    47847           
  Misses       3994     3994
```

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


------

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

```diff
@@            Coverage Diff             @@
##           master   #24377      +/-   ##
==========================================
- Coverage    92.3%    92.3%   -0.01%     
==========================================
  Files         162      163       +1     
  Lines       51875    51947      +72     
==========================================
+ Hits        47883    47949      +66     
- Misses       3992     3998       +6
```

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

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24377?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `97.77% <0%> (-0.47%)` | :arrow_down: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `86.85% <0%> (-0.31%)` | :arrow_down: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `96.35% <0%> (-0.16%)` | :arrow_down: |
| [pandas/core/indexes/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy90aW1lZGVsdGFzLnB5) | `90.42% <0%> (-0.03%)` | :arrow_down: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `98.49% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `96.33% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.27% <0%> (ø)` | :arrow_up: |
| [pandas/core/arrays/\_ranges.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL19yYW5nZXMucHk=) | `98.66% <0%> (ø)` | |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `97.29% <0%> (ø)` | :arrow_up: |
| [pandas/core/tools/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvdG9vbHMvZGF0ZXRpbWVzLnB5) | `85.32% <0%> (+0.04%)` | :arrow_up: |
| ... and [1 more](https://codecov.io/gh/pandas-dev/pandas/pull/24377/diff?src=pr&el=tree-more) | |

------

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

@jreback 

> on master we have 499 tests and 139 skipped, here 497 ad 9 skipped. so I think a couple got removed?

for `TestDatetimeIndex::test_resample_empty_dtypes`

```
$ pytest pandas/tests/resample/test_base.py::TestDatetimeIndex::test_resample_empty_dtypes
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.7.3, py-1.5.4, pluggy-0.7.1
rootdir: C:\Users\simon\OneDrive\code\pandas-simonjayhawkins, inifile: setup.cfg
plugins: xdist-1.23.0, forked-0.2, cov-2.5.1, hypothesis-3.59.1
collected 192 items

pandas\tests\resample\test_base.py ..................................... [ 19%]
........................................................................ [ 56%]
........................................................................ [ 94%]
...........                                                              [100%]

========================= 192 passed in 1.55 seconds ==========================
```

similarly for `TestPeriodIndex`

```
$ pytest pandas/tests/resample/test_base.py::TestPeriodIndex::test_resample_empty_dtypes
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.7.3, py-1.5.4, pluggy-0.7.1
rootdir: C:\Users\simon\OneDrive\code\pandas-simonjayhawkins, inifile: setup.cfg
plugins: xdist-1.23.0, forked-0.2, cov-2.5.1, hypothesis-3.59.1
collected 192 items

pandas\tests\resample\test_base.py ..................................... [ 19%]
........................................................................ [ 56%]
........................................................................ [ 94%]
...........                                                              [100%]

========================= 192 passed in 1.10 seconds ==========================
```

and the same for `TestTimedeltaIndex`

but because `test_resample_empty_dtypes` is paramatrized using a generator it was misbehaving..

```
$ pytest pandas/tests/resample/test_base.py -k test_resample_empty_dtypes
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.7.3, py-1.5.4, pluggy-0.7.1
rootdir: C:\Users\simon\OneDrive\code\pandas-simonjayhawkins, inifile: setup.cfg
plugins: xdist-1.23.0, forked-0.2, cov-2.5.1, hypothesis-3.59.1
collected 638 items / 318 deselected

pandas\tests\resample\test_base.py ..................................... [ 11%]
........................................................................ [ 34%]
........................................................................ [ 56%]
...........sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 79%]
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss      [100%]

=========== 192 passed, 128 skipped, 318 deselected in 1.43 seconds ===========

```

so that account for 128 of the 130 reduction in skipped tests. the other two are from the overridden tests...

https://github.com/pandas-dev/pandas/blob/1cd077a3077352d63c1226d554db1e46cb9d2c1a/pandas/tests/resample/test_base.py#L231-L237

the number of passed tests is reduced by two since `test_raises_on_non_datetimelike_index` is not dependent on index type so is now only run once instead of 3 times.

https://github.com/pandas-dev/pandas/blob/1cd077a3077352d63c1226d554db1e46cb9d2c1a/pandas/tests/resample/test_base.py#L71-L74
```
_____________ ERROR collecting pandas/tests/resample/test_base.py _____________
2018-12-23T18:59:10.6286537Z C:\Miniconda\envs\pandas-dev\lib\site-packages\_pytest\python.py:450: in _importtestmodule
2018-12-23T18:59:10.6287402Z     mod = self.fspath.pyimport(ensuresyspath=importmode)
2018-12-23T18:59:10.6287666Z C:\Miniconda\envs\pandas-dev\lib\site-packages\py\_path\local.py:668: in pyimport
2018-12-23T18:59:10.6287846Z     __import__(modname)
2018-12-23T18:59:10.6288006Z E     File "D:\a\1\s\pandas\tests\resample\test_base.py", line 21
2018-12-23T18:59:10.6288224Z E   SyntaxError: Non-ASCII character '\xe2' in file D:\a\1\s\pandas\tests\resample\test_base.py on line 21, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
2018-12-23T18:59:10.629434
```
thanks @simonjayhawkins