TST: Timestamp and Timeseries tests reorg (gh14854)
State: closed

 - [x] Partially completes #14854 
 - [x] Tests reorganized (```test_timeseries.py``` + ```test_tslib.py``` -> ```test_timestamp.py```)
 - [x] Passes ``git diff upstream/master | flake8 --diff``


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

Comments:
lgtm. the remainder of ``tseries/test_timeseries.py`` can prob go in ``tests/series/test_timestamp.py`` (or can move the obvious stuff). Then can look and see what remains.

thanks!
Wouldn't the remaining tests of ```tseries/test_timeseries.py``` go in ```tests/series/test_timeseries.py``` instead of ```tests/series/test_timestamp.py```? You have also mentioned the same in the issue ( #14854 3rd point).
@TrigonaMinima yes, sorry, that's what I meant!

of course if you find say a period test or something, move to the appropriate place.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15301?src=pr&el=h1) Report
> Merging [#15301](https://codecov.io/gh/pandas-dev/pandas/pull/15301?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/9ddba8dc811184c49d9bc4df5dc97d505345ec23?src=pr&el=desc) will **not impact** coverage.


```diff
@@           Coverage Diff           @@
##           master   #15301   +/-   ##
=======================================
  Coverage   86.33%   86.33%           
=======================================
  Files         139      139           
  Lines       51149    51149           
=======================================
  Hits        44157    44157           
  Misses       6992     6992
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15301?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/15301?src=pr&el=footer). Last update [9ddba8d...285387f](https://codecov.io/gh/pandas-dev/pandas/compare/9ddba8dc811184c49d9bc4df5dc97d505345ec23...285387f6909adb3ff9d27436ee27f6878916e043?src=pr&el=footer&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
ok a lot of the move into tests/series/test_timestamp.py was composed of things (that can be split out)

- fillna (on series) can go to test_missing
- move pure date_range tests an go to indexes/datetimes/test_date_range (new file)
- maybe some pure Timestamp things to scalar/test_timestamp

You meant ```tests/series/test_timeseries.py```, right? :smile: 

It's still large though.

@TrigonaMinima yeah. Need to separate pieces out as much as possible (though still may end up large). ok for now. I'll take a look and move more.
@TrigonaMinima just ping on green. I'll do a follow on this stuff to fix a couple of little points.

If you can continue on to other things would be great!
@TrigonaMinima don't push anymore to this. I have already taken your commit (and going to merge it soon), along with a bunch of other changes.
Sure. When I pushed it there wasn't anything. Sorry for that.
@TrigonaMinima no prob. 

https://github.com/pandas-dev/pandas/compare/master...jreback:fix-tests?expand=1

is the diff
@TrigonaMinima if you are game, love to move timedelta and period in a similar way (e.g. move the scalar tests and index tests). you can create a ``indexes/timedeltas,period`` sub-dir

e.g. for timedelta separate out the ``to_timedelta`` stuff into a separate file apart from *multiple* files for timedelta index consruction / ops etc.

similar for period.
also you can move ``tserites/tests/test_daterange.py`` to ``indexes/datetimes/test_date_range`` (add to same file).
and ``tseries/tests/test_tslib.py`` can go to (you will have to move classes / individual test)
can also hit ``tseires/tests_util.py`` at same time I think.

- test_timezones.py (only move stuff that is actually doing timezone stuff, not *parsing* timezones, that will be in below)
- indexes/datetimes/test_tools.py (for parsing and tslib.* routines)
- test_period.py 
- a couple of random things at the bottom have to find a good spot.

do this *after* I merge (shortly) and separately from everything else as this will touch lots of things.
@jreback sure. I just have a couple of questions-

- Why are there tests outside tests directory? What's the difference between these tests in ```pandas/tests``` and in each sub directory under pandas? Is it by design?
- What goes under scalars and what goes under indexes. Some routines seemed to me as if they could go anywhere. So if there is some part of documentation where i can know the difference or may be you can explain it to me.

Also, just clarifying, I should do timedelta changes in a different PR right?
yes, leave this PR alone. timedelta is a separate PR.

in *theory* everything should be under ``pandas/tests`` (sub-dirs of). but we have historically not done that, so slowly moving things.

so in the scalar dir are ``Timestamp``, ``Timedelta``, ``Period`` specific things, as opposed to ``DatetimeIndex``, ``TimedeltaIndex``, ``PeriodIndex`` (which are the indexes which wrap these scalars).

e.g. a method/property of ``Timestamp`` belongs in scalar, while *using* ``Timestamp`` to say subtract from a ``DatetimeIndex`` belong in indexes.

the tests dir *should* be almost self-explanatory, with it obvious where a new tests should go. there should be 1 and only 1 place.
merged!
Thanks. The explanation made things clearer.