|
14 | 14 | tzlocal,
|
15 | 15 | tzutc,
|
16 | 16 | )
|
| 17 | +from hypothesis import given |
17 | 18 | import numpy as np
|
18 | 19 | import pytest
|
19 | 20 | import pytz
|
|
36 | 37 | Timestamp,
|
37 | 38 | )
|
38 | 39 | import pandas._testing as tm
|
| 40 | +from pandas._testing._hypothesis import DATETIME_IN_PD_TIMESTAMP_RANGE_NO_TZ |
39 | 41 |
|
40 | 42 | from pandas.tseries import offsets
|
41 | 43 | from pandas.tseries.frequencies import to_offset
|
@@ -224,14 +226,29 @@ def test_resolution(self):
|
224 | 226 | assert dt.as_unit("s").resolution == Timedelta(seconds=1)
|
225 | 227 |
|
226 | 228 | @pytest.mark.parametrize(
|
227 |
| - "date_string,expected", |
228 |
| - [("0000-2-29", 1), ("0000-3-1", 2), ("1582-10-14", 3), ("1582-10-15", 4)], |
| 229 | + "date_string, expected_true, expected_false", |
| 230 | + [ |
| 231 | + ("0000-2-29", 1, 2), |
| 232 | + ("0000-3-1", 2, 3), |
| 233 | + ("1582-10-14", 3, 4), |
| 234 | + ("1582-10-15", 4, 5), |
| 235 | + ("1752-01-01", 5, 6), |
| 236 | + ("2023-06-18", 6, 0), |
| 237 | + ], |
229 | 238 | )
|
230 |
| - def test_dow_historic(self, date_string, expected): |
| 239 | + def test_dow_historic(self, date_string, expected_true, expected_false): |
231 | 240 | # GH 53738
|
232 | 241 | dt = Timestamp(date_string)
|
233 | 242 | dow = dt.weekday()
|
234 |
| - assert dow == expected |
| 243 | + assert dow == expected_true |
| 244 | + assert not dow == expected_false |
| 245 | + |
| 246 | + @given(DATETIME_IN_PD_TIMESTAMP_RANGE_NO_TZ) |
| 247 | + def test_dow_sanity(self, dt): |
| 248 | + # GH 53738 |
| 249 | + expected = dt.weekday() |
| 250 | + result = datetime(dt.year, dt.month, dt.day).weekday() |
| 251 | + assert result == expected |
235 | 252 |
|
236 | 253 |
|
237 | 254 | class TestTimestamp:
|
|
0 commit comments