From 3363b0b446e0db9e5cc02a62cd6479c3fa49e1e0 Mon Sep 17 00:00:00 2001 From: OlivierLuG Date: Sun, 7 Jun 2020 10:51:21 +0200 Subject: [PATCH 1/2] TST #24444 added tests --- pandas/tests/scalar/period/test_period.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index 42bd20fd9640b..e6b2db6ccde9e 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -649,6 +649,26 @@ def test_to_timestamp_business_end(self): expected = pd.Timestamp("1990-01-06") - pd.Timedelta(nanoseconds=1) assert result == expected + @pytest.mark.parametrize( + "ts, expected", + [ + ("1970-01-01 00:00:00", 0), + ("1970-01-01 00:00:00.000001", 1), + ("1970-01-01 00:00:00.00001", 10), + ("1970-01-01 00:00:00.499", 499000), + ("1999-12-31 23:59:59.999", 999000), + ("1999-12-31 23:59:59.999999", 999999), + ("2050-12-31 23:59:59.5", 500000), + ("2050-12-31 23:59:59.500001", 500001), + ("2050-12-31 23:59:59.123456", 123456), + ], + ) + @pytest.mark.parametrize("freq", [None, "us", "ns"]) + def test_to_timestamp_microsecond(self, ts, expected, freq): + # GH 24444 + result = Period(f"{ts}").to_timestamp(freq=freq).microsecond + assert result == expected + # -------------------------------------------------------------- # Rendering: __repr__, strftime, etc From 8ab569a0e1478cb4fc96bd8599f6ff432e556ca6 Mon Sep 17 00:00:00 2001 From: OlivierLuG <59281854+OlivierLuG@users.noreply.github.com> Date: Sun, 7 Jun 2020 18:12:29 +0200 Subject: [PATCH 2/2] TST #24444 added tests The test was modified according to review --- pandas/tests/scalar/period/test_period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/scalar/period/test_period.py b/pandas/tests/scalar/period/test_period.py index e6b2db6ccde9e..3e769b577582a 100644 --- a/pandas/tests/scalar/period/test_period.py +++ b/pandas/tests/scalar/period/test_period.py @@ -666,7 +666,7 @@ def test_to_timestamp_business_end(self): @pytest.mark.parametrize("freq", [None, "us", "ns"]) def test_to_timestamp_microsecond(self, ts, expected, freq): # GH 24444 - result = Period(f"{ts}").to_timestamp(freq=freq).microsecond + result = Period(ts).to_timestamp(freq=freq).microsecond assert result == expected # --------------------------------------------------------------