TST: Tests and Helpers for Datetime/Period Arrays
State: closed

Implement ABCDatetimeArray, ABCTimedeltaArray

Fix some problems in DatetimeArray comparison methods, with tests

Implement assert_datetime_array_equal, still need to do the same for TimedeltaArray

Extend fixtures to allow us to run some of the arithmetic tests on PeriodArray, DatetimeArray.  Change a few usages to use these fixtures.

This is a companion-PR to #23493.  Without that one, we can't easily extend the existing tests.  Without this one, problems in the comparison methods would cause failures.



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

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

 - There are no PEP8 issues in the file [`pandas/core/arrays/datetimelike.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/core/arrays/datetimelike.py) !

 - There are no PEP8 issues in the file [`pandas/core/arrays/datetimes.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/core/arrays/datetimes.py) !

 - There are no PEP8 issues in the file [`pandas/core/arrays/period.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/core/arrays/period.py) !

 - There are no PEP8 issues in the file [`pandas/core/arrays/timedeltas.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/core/arrays/timedeltas.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/generic.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/core/dtypes/generic.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arithmetic/conftest.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/tests/arithmetic/conftest.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arithmetic/test_datetime64.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/tests/arithmetic/test_datetime64.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arithmetic/test_period.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/tests/arithmetic/test_period.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arrays/test_datetimes.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/tests/arrays/test_datetimes.py) !

 - There are no PEP8 issues in the file [`pandas/util/testing.py`](https://github.com/jbrockmendel/pandas/blob/d1188ac69d603b8dae02b13f873bc44d784a0f5a/pandas/util/testing.py) !


> This is a companion-PR to #23493. Without that one, we can't easily extend the existing tests. Without this one, problems in the comparison methods would cause failures.

But do they depend on each other? (meaning, does one need to be merged before the other, or they are orthogonal implementation-wise?)
> But do they depend on each other? (meaning, does one need to be merged before the other, or they are orthogonal implementation-wise?)

They are orthogonal implementation-wise.  They are both needed in order to make major progress on sharing existing tests.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23502?src=pr&el=h1) Report
> Merging [#23502](https://codecov.io/gh/pandas-dev/pandas/pull/23502?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/ce62a5c12069c3ac54c65fdca41d3c0a473b3dfb?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `93.33%`.

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

```diff
@@            Coverage Diff             @@
##           master   #23502      +/-   ##
==========================================
- Coverage   92.25%   92.25%   -0.01%     
==========================================
  Files         161      161              
  Lines       51237    51260      +23     
==========================================
+ Hits        47269    47290      +21     
- Misses       3968     3970       +2
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.63% <93.33%> (ø)` | :arrow_up: |
| #single | `42.33% <43.33%> (+0.03%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23502?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/arrays/period.py](https://codecov.io/gh/pandas-dev/pandas/pull/23502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3BlcmlvZC5weQ==) | `98.08% <ø> (-0.01%)` | :arrow_down: |
| [pandas/core/arrays/datetimelike.py](https://codecov.io/gh/pandas-dev/pandas/pull/23502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lbGlrZS5weQ==) | `95.92% <100%> (+0.02%)` | :arrow_up: |
| [pandas/core/arrays/timedeltas.py](https://codecov.io/gh/pandas-dev/pandas/pull/23502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL3RpbWVkZWx0YXMucHk=) | `93.78% <100%> (+0.03%)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/23502/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `86.78% <100%> (+0.14%)` | :arrow_up: |
| [pandas/core/dtypes/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/23502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2dlbmVyaWMucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/arrays/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23502/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvYXJyYXlzL2RhdGV0aW1lcy5weQ==) | `98.42% <84.61%> (-0.43%)` | :arrow_down: |

------

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

There seemed to be an install error with one of the windows workers. Triggered a rebuild.
rebuild green
Travis failure looks wonky and unrelated
Thanks @jbrockmendel !