Refactor index-as-string groupby tests and fix spurious warning (Bug 17383)
State: closed

- [x] closes #17383 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

Test case refactoring:
  - Moved the existing  index-as-string test cases out of `test_groupby.py` and into a new `test_index_as_string.py` file
  - Extracted test data generation functions and parameterized existing test cases to clean them up and shorten them.
  - Added a new parameterized test case on a `Series`
  - Updated `test_grouper_column_index_level_precedence` to reproduce false warning problem as described in #17383 
  - Updated `test_grouper_column_index_level_precedence` to verify when warnings should **NOT** be raised (Results in a test failure due to #17383 without this fix)


Labels:
name: Groupby
name: API Design

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

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

```diff
@@            Coverage Diff             @@
##           master   #17843      +/-   ##
==========================================
- Coverage   91.22%   91.22%   -0.01%     
==========================================
  Files         163      163              
  Lines       50014    50075      +61     
==========================================
+ Hits        45627    45679      +52     
- Misses       4387     4396       +9
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.03% <100%> (+0.01%)` | :arrow_up: |
| #single | `40.32% <0%> (+0.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/groupby.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS5weQ==) | `91.98% <100%> (-0.02%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :arrow_down: |
| [pandas/compat/numpy/function.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2NvbXBhdC9udW1weS9mdW5jdGlvbi5weQ==) | `92.12% <0%> (-1.22%)` | :arrow_down: |
| [pandas/core/indexing.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhpbmcucHk=) | `92.82% <0%> (-0.19%)` | :arrow_down: |
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `95.94% <0%> (-0.13%)` | :arrow_down: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.75% <0%> (-0.12%)` | :arrow_down: |
| [pandas/core/computation/align.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29tcHV0YXRpb24vYWxpZ24ucHk=) | `97.89% <0%> (-0.05%)` | :arrow_down: |
| [pandas/core/reshape/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9jb25jYXQucHk=) | `97.57% <0%> (-0.04%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.47% <0%> (-0.01%)` | :arrow_down: |
| ... and [16 more](https://codecov.io/gh/pandas-dev/pandas/pull/17843?src=pr&el=tree-more) | |

------

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

Thanks for the feedback @jreback.  I think I've made all the changes you requested and I learned some things about pytest along the way.
thank @jmmease nice patch! keep em coming!