TST: resolve issues with test_constructor_dtype_datetime64
State: closed

closes #24827
xref https://github.com/pandas-dev/pandas/pull/24812#discussion_r248666576

while changing pytest.raises to use the context manager and check the error message it appeared that a test was not raising exceptions as originally intended.

the test was related to a legacy numpy related issue #3414

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

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/24868?src=pr&el=h1) Report
> Merging [#24868](https://codecov.io/gh/pandas-dev/pandas/pull/24868?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/12bb6d0536b947f74b66ebe18b5f451bfdd7453f?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #24868   +/-   ##
=======================================
  Coverage   92.38%   92.38%           
=======================================
  Files         166      166           
  Lines       52412    52412           
=======================================
  Hits        48423    48423           
  Misses       3989     3989
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.81% <ø> (ø)` | :arrow_up: |
| #single | `42.89% <ø> (ø)` | :arrow_up: |


------

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

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

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

```diff
@@            Coverage Diff             @@
##           master   #24868      +/-   ##
==========================================
- Coverage   91.25%   91.25%   -0.01%     
==========================================
  Files         172      172              
  Lines       52963    52963              
==========================================
- Hits        48330    48329       -1     
- Misses       4633     4634       +1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.82% <ø> (ø)` | :arrow_up: |
| #single | `41.74% <ø> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/24868?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/24868/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.98% <0%> (-0.1%)` | :arrow_down: |

------

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

Can you merge master and address latest comments?

Also, it may just be me but I would find it super helpful going forward if you could use a more descriptive title here and for future PRs. We have a rather large backlog of PRs and issues so if it's not descriptive it's more work than it needs to be on the review end to keep track of what the PR is trying to address
Closing as stale - ping if you'd like to continue
@WillAyd : i'll need to resolve this at some point before we can activate the code checks for pytest.raises not been used as a context manager.

This PR was closely related to #24827. There is no longer any activity there. So i'll include that here and change the title to relate to that issue.
 
So if you could reopen this PR that'll be great. Thanks.
@simonjayhawkins done!
thanks. @WillAyd. I believe the comments have been addressed. will merge master and uncomment the current solution to #24827 which i believe @jreback  was happy with, see https://github.com/pandas-dev/pandas/pull/24812#discussion_r248656502 and use np.intp to resolve the windows issue. Then see where we go from there.
thanks @simonjayhawkins note that the test itself is pretty long (not your change), so can consider breaking it up a bit in the future.