TST: Parametrize simple yield tests
State: closed

Simple `yield` tests are those that do `for x in y: yield test, x` where `y` is some constant list/tuple. It also requires the tests to be in a simple class that doesn't subclass `unittest`'s classes (because parametrization doesn't work there).

There are still `yield` tests in 
 * frame/test_query_eval.py
 * io/test_packers.py
 * io/test_pickle.py
 * test_internals.py
 * test_window.py

but I haven't changed them since they don't conform to the requirements above.

This is also not an attempt to parametrize any and all test loops.

 - [x] cf #15341
 - [ ] tests added / passed
 - [x] passes ``git diff upstream/master | flake8 --diff``
 - [ ] whatsnew entry


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

Comments:
@QuLogic thanks for starting on this!

If it helps, you can (temporarily) remove the line

```
addopts = --disable-pytest-warnings
```

in `setup.cfg` so that the warnings aren't suppressed.
Thanks @TomAugspurger; somehow I'm still getting warnings anyway (in most cases).
@QuLogic ok merged. give your changes a rebase and try.
@QuLogic I think you have a linting error and

``Different tests were collected between gw1 and gw0. The difference is:`` on the OSX test, very odd.

FYI the warnings are now showing on windows (had to fix the build for other reasons):

https://ci.appveyor.com/project/jreback/pandas/build/1.0.3009/job/4xo1hvnr0kb2jjo6

so in next PR should fix these :<
Oops, I guess `flake8 --diff` doesn't catch that sort of linting error.

The xdist thing is a bug in pytest-xdist pytest-dev/pytest#920; we have [this workaround](https://github.com/matplotlib/matplotlib/blob/master/.travis.yml#L154-L158).
@QuLogic ahh if you want to add that work-around for xdist to ``ci/scripts_multiple.py`` would be fine. 
yeah the flake checker on travis picks up these types of things but for some reason it doesn't locally. not sure why.
@QuLogic this looks good. windows completed, so ping on green on travis.
https://travis-ci.org/pandas-dev/pandas/jobs/202066838

hmm, can you add in the PYTHONHASHSEED setting? (ci/scripts_multiple.py)
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15406?src=pr&el=h1) Report
> Merging [#15406](https://codecov.io/gh/pandas-dev/pandas/pull/15406?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/d6f8b460325fd79faa90858e2743878a7cc74dec?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `80%`.


```diff
@@            Coverage Diff             @@
##           master   #15406      +/-   ##
==========================================
+ Coverage   90.36%   90.37%   +<.01%     
==========================================
  Files         135      135              
  Lines       49438    49440       +2     
==========================================
+ Hits        44675    44680       +5     
+ Misses       4763     4760       -3
```


| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/15406?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/compare/d6f8b460325fd79faa90858e2743878a7cc74dec...b002752adb8157169bf1b635f5e38552a2df4602?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `82.09% <80%> (+0.31%)` | :white_check_mark: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15406?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/15406?src=pr&el=footer). Last update [d6f8b46...b002752](https://codecov.io/gh/pandas-dev/pandas/compare/d6f8b460325fd79faa90858e2743878a7cc74dec...b002752adb8157169bf1b635f5e38552a2df4602?src=pr&el=footer&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
thanks @QuLogic nice fixes!

keep em coming!
Do you squash locally or something? Seems odd PR is closed instead of merged...
no this is merged !

you don't need to squash generally as it's done in merge
https://github.com/pandas-dev/pandas/commit/ddb22f578b7c7147fd8bcd9fb7c8504a8053e313
@QuLogic looks like: frame/test_query_eval.py is not giving any yield errors AFAICT
It does use `yield`, but I think because they're in classes subclassed from `tm.TestCase`(which is a `unittest.TestCase` subclass), they don't cause any warnings. Being such a subclass also means you can't use `pytest.parametrize` anyway, but it's something to keep in mind if `tm.TestCase` is modified.
@QuLogic ahh ok. yeah the need for subclassing ``tm.TestCase`` is much less (as we needed certain things like ``self.assertTrue`` to be unified).