TST: add test cases for reset_index method
State: closed

- [x] closes #17067
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

the fix appears to work but it breaks previous assert_frame_equal that assumes index.name == None after reset_index() call. 

The question remains that is the issue #17067 actually a bug and does it require a fix at all? user can pretty much do `series.index.name = 'new name'` to handle this problem.

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

Comments:
Hello @minggli! Thanks for submitting the PR.

 - There are no PEP8 issues in the file [`pandas/core/frame.py`](https://github.com/minggli/pandas/blob/81f64df53b92824d8772a4f6baddeb67bfd9d29f/pandas/core/frame.py) !

 - There are no PEP8 issues in the file [`pandas/core/indexes/base.py`](https://github.com/minggli/pandas/blob/81f64df53b92824d8772a4f6baddeb67bfd9d29f/pandas/core/indexes/base.py) !

 - There are no PEP8 issues in the file [`pandas/core/series.py`](https://github.com/minggli/pandas/blob/81f64df53b92824d8772a4f6baddeb67bfd9d29f/pandas/core/series.py) !


there are 2 issues pointed out in the OP

the first should already be fixed (and was a bug)

to answer your question, yes we want to be consistent in this
@jreback thanks for commenting! it seems it has indeed been fixed already. closing this PR.
would take tests for this though!
strangely, it appears that below would fail on master:

```python3
s = pd.Series([1, 2, 3], index=pd.Index(range(3), name='x'))
assert s.reset_index().index.name == 'x'
assert s.reset_index(drop=True).index.name == 'x'
```
i hope I understood the issue correctly, is it expected for the reset index to carry over the index name?

```
In [11]: s.reset_index(drop=True).index.name == 'x'
Out[11]: False

In [12]: s.reset_index().index.name == 'x'
Out[12]: False
```
these both look correct to me, the index name *should* not be carried over.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23116?src=pr&el=h1) Report
> Merging [#23116](https://codecov.io/gh/pandas-dev/pandas/pull/23116?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/ecc5cbc64ea44e010fa7fe9d25e3064926594b09?src=pr&el=desc) will **increase** coverage by `0.62%`.
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff             @@
##           master   #23116      +/-   ##
==========================================
+ Coverage   92.19%   92.82%   +0.62%     
==========================================
  Files         169      169              
  Lines       50950    55686    +4736     
==========================================
+ Hits        46975    51689    +4714     
- Misses       3975     3997      +22
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `91.37% <ø> (+0.75%)` | :arrow_up: |
| #single | `43.7% <ø> (+1.43%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23116?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NvbW1vbi5weQ==) | `68.62% <0%> (-2.42%)` | :arrow_down: |
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `95.47% <0%> (-0.1%)` | :arrow_down: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `86.5% <0%> (+0.05%)` | :arrow_up: |
| [pandas/core/indexes/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZWxpa2UucHk=) | `98.37% <0%> (+0.12%)` | :arrow_up: |
| [pandas/io/formats/csvs.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvY3N2cy5weQ==) | `98.39% <0%> (+0.17%)` | :arrow_up: |
| [pandas/core/arrays/categorical.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2NhdGVnb3JpY2FsLnB5) | `95.74% <0%> (+0.2%)` | :arrow_up: |
| [pandas/core/arrays/sparse.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3NwYXJzZS5weQ==) | `92.76% <0%> (+0.24%)` | :arrow_up: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `95.57% <0%> (+0.67%)` | :arrow_up: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `98.05% <0%> (+0.67%)` | :arrow_up: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.84% <0%> (+0.72%)` | :arrow_up: |
| ... and [12 more](https://codecov.io/gh/pandas-dev/pandas/pull/23116/diff?src=pr&el=tree-more) | |

------

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

@jreback reflected your comment in added tests.
thanks @minggli 
welcome! @jreback @gfyoung 😃