Skip to content

Commit 4449cf9

Browse files
jbrockmendelMateusz Górski
authored and
Mateusz Górski
committed
TST: cln runtime imports in some tests (pandas-dev#29560)
1 parent c07bdb5 commit 4449cf9

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

pandas/tests/scalar/period/test_period.py

+10
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ def test_add_sub_nat(self):
10441044
assert NaT - p is NaT
10451045

10461046
p = Period("NaT", freq="M")
1047+
assert p is NaT
10471048
assert p + NaT is NaT
10481049
assert NaT + p is NaT
10491050
assert p - NaT is NaT
@@ -1284,6 +1285,7 @@ def test_add_offset_nat(self):
12841285
# freq is DateOffset
12851286
for freq in ["A", "2A", "3A"]:
12861287
p = Period("NaT", freq=freq)
1288+
assert p is NaT
12871289
for o in [offsets.YearEnd(2)]:
12881290
assert p + o is NaT
12891291
assert o + p is NaT
@@ -1300,6 +1302,7 @@ def test_add_offset_nat(self):
13001302

13011303
for freq in ["M", "2M", "3M"]:
13021304
p = Period("NaT", freq=freq)
1305+
assert p is NaT
13031306
for o in [offsets.MonthEnd(2), offsets.MonthEnd(12)]:
13041307
assert p + o is NaT
13051308
assert o + p is NaT
@@ -1317,6 +1320,7 @@ def test_add_offset_nat(self):
13171320
# freq is Tick
13181321
for freq in ["D", "2D", "3D"]:
13191322
p = Period("NaT", freq=freq)
1323+
assert p is NaT
13201324
for o in [
13211325
offsets.Day(5),
13221326
offsets.Hour(24),
@@ -1340,6 +1344,7 @@ def test_add_offset_nat(self):
13401344

13411345
for freq in ["H", "2H", "3H"]:
13421346
p = Period("NaT", freq=freq)
1347+
assert p is NaT
13431348
for o in [
13441349
offsets.Day(2),
13451350
offsets.Hour(3),
@@ -1439,6 +1444,7 @@ def test_sub_offset_nat(self):
14391444
# freq is DateOffset
14401445
for freq in ["A", "2A", "3A"]:
14411446
p = Period("NaT", freq=freq)
1447+
assert p is NaT
14421448
for o in [offsets.YearEnd(2)]:
14431449
assert p - o is NaT
14441450

@@ -1453,6 +1459,7 @@ def test_sub_offset_nat(self):
14531459

14541460
for freq in ["M", "2M", "3M"]:
14551461
p = Period("NaT", freq=freq)
1462+
assert p is NaT
14561463
for o in [offsets.MonthEnd(2), offsets.MonthEnd(12)]:
14571464
assert p - o is NaT
14581465

@@ -1468,6 +1475,7 @@ def test_sub_offset_nat(self):
14681475
# freq is Tick
14691476
for freq in ["D", "2D", "3D"]:
14701477
p = Period("NaT", freq=freq)
1478+
assert p is NaT
14711479
for o in [
14721480
offsets.Day(5),
14731481
offsets.Hour(24),
@@ -1489,6 +1497,7 @@ def test_sub_offset_nat(self):
14891497

14901498
for freq in ["H", "2H", "3H"]:
14911499
p = Period("NaT", freq=freq)
1500+
assert p is NaT
14921501
for o in [
14931502
offsets.Day(2),
14941503
offsets.Hour(3),
@@ -1511,6 +1520,7 @@ def test_sub_offset_nat(self):
15111520
@pytest.mark.parametrize("freq", ["M", "2M", "3M"])
15121521
def test_nat_ops(self, freq):
15131522
p = Period("NaT", freq=freq)
1523+
assert p is NaT
15141524
assert p + 1 is NaT
15151525
assert 1 + p is NaT
15161526
assert p - 1 is NaT

pandas/tests/scalar/timestamp/test_timestamp.py

-4
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ def test_constructor(self):
202202
base_expected = 1404205200000000000
203203

204204
# confirm base representation is correct
205-
import calendar
206-
207205
assert calendar.timegm(base_dt.timetuple()) * 1000000000 == base_expected
208206

209207
tests = [
@@ -275,8 +273,6 @@ def test_constructor_with_stringoffset(self):
275273
base_expected = 1404205200000000000
276274

277275
# confirm base representation is correct
278-
import calendar
279-
280276
assert calendar.timegm(base_dt.timetuple()) * 1000000000 == base_expected
281277

282278
tests = [

pandas/tests/scalar/timestamp/test_timezones.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,14 @@ def test_astimezone(self, tzstr):
306306

307307
@td.skip_if_windows
308308
def test_tz_convert_utc_with_system_utc(self):
309-
from pandas._libs.tslibs.timezones import maybe_get_tz
310309

311310
# from system utc to real utc
312-
ts = Timestamp("2001-01-05 11:56", tz=maybe_get_tz("dateutil/UTC"))
311+
ts = Timestamp("2001-01-05 11:56", tz=timezones.maybe_get_tz("dateutil/UTC"))
313312
# check that the time hasn't changed.
314313
assert ts == ts.tz_convert(dateutil.tz.tzutc())
315314

316315
# from system utc to real utc
317-
ts = Timestamp("2001-01-05 11:56", tz=maybe_get_tz("dateutil/UTC"))
316+
ts = Timestamp("2001-01-05 11:56", tz=timezones.maybe_get_tz("dateutil/UTC"))
318317
# check that the time hasn't changed.
319318
assert ts == ts.tz_convert(dateutil.tz.tzutc())
320319

0 commit comments

Comments
 (0)