From 2bab71896fdc971abc2900151a07b624f4e8bc94 Mon Sep 17 00:00:00 2001 From: jreback Date: Fri, 15 May 2015 16:57:30 -0400 Subject: [PATCH] TST: windows tests for allow for int/long #10050 --- pandas/tseries/tests/test_timedeltas.py | 26 ++++++++------ pandas/tseries/tests/test_tslib.py | 48 +++++++++++-------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/pandas/tseries/tests/test_timedeltas.py b/pandas/tseries/tests/test_timedeltas.py index ae868af60ae63..c5843862306ca 100644 --- a/pandas/tseries/tests/test_timedeltas.py +++ b/pandas/tseries/tests/test_timedeltas.py @@ -309,6 +309,10 @@ class Other: def test_fields(self): + def check(value): + # that we are int/long like + self.assertTrue(isinstance(value, (int, long))) + # compat to datetime.timedelta rng = to_timedelta('1 days, 10:11:12') self.assertEqual(rng.days, 1) @@ -321,10 +325,10 @@ def test_fields(self): self.assertRaises(AttributeError, lambda : rng.milliseconds) # GH 10050 - self.assertTrue(isinstance(rng.days, int)) - self.assertTrue(isinstance(rng.seconds, int)) - self.assertTrue(isinstance(rng.microseconds, int)) - self.assertTrue(isinstance(rng.nanoseconds, int)) + check(rng.days) + check(rng.seconds) + check(rng.microseconds) + check(rng.nanoseconds) td = Timedelta('-1 days, 10:11:12') self.assertEqual(abs(td), Timedelta('13:48:48')) @@ -353,13 +357,13 @@ def test_fields(self): self.assertEqual(tup.nanoseconds, 0) # GH 10050 - self.assertTrue(isinstance(tup.days, int)) - self.assertTrue(isinstance(tup.hours, int)) - self.assertTrue(isinstance(tup.minutes, int)) - self.assertTrue(isinstance(tup.seconds, int)) - self.assertTrue(isinstance(tup.milliseconds, int)) - self.assertTrue(isinstance(tup.microseconds, int)) - self.assertTrue(isinstance(tup.nanoseconds, int)) + check(tup.days) + check(tup.hours) + check(tup.minutes) + check(tup.seconds) + check(tup.milliseconds) + check(tup.microseconds) + check(tup.nanoseconds) tup = Timedelta('-1 days 1 us').components self.assertEqual(tup.days, -2) diff --git a/pandas/tseries/tests/test_tslib.py b/pandas/tseries/tests/test_tslib.py index 6b3dd63e6415b..27e5b927f9719 100644 --- a/pandas/tseries/tests/test_tslib.py +++ b/pandas/tseries/tests/test_tslib.py @@ -370,37 +370,29 @@ def test_today(self): - ts_from_method_tz.tz_localize(None)) < delta) def test_fields(self): + + def check(value, equal): + # that we are int/long like + self.assertTrue(isinstance(value, (int, long))) + self.assertEqual(value, equal) + # GH 10050 ts = Timestamp('2015-05-10 09:06:03.000100001') - self.assertEqual(ts.year, 2015) - self.assertTrue(isinstance(ts.year, int)) - self.assertEqual(ts.month, 5) - self.assertTrue(isinstance(ts.month, int)) - self.assertEqual(ts.day, 10) - self.assertTrue(isinstance(ts.day, int)) - self.assertEqual(ts.hour, 9) - self.assertTrue(isinstance(ts.hour, int)) - self.assertEqual(ts.minute, 6) - self.assertTrue(isinstance(ts.minute, int)) - self.assertEqual(ts.second, 3) - self.assertTrue(isinstance(ts.second, int)) + check(ts.year, 2015) + check(ts.month, 5) + check(ts.day, 10) + check(ts.hour, 9) + check(ts.minute, 6) + check(ts.second, 3) self.assertRaises(AttributeError, lambda : ts.millisecond) - self.assertEqual(ts.microsecond, 100) - self.assertTrue(isinstance(ts.microsecond, int)) - self.assertEqual(ts.nanosecond, 1) - self.assertTrue(isinstance(ts.nanosecond, int)) - self.assertEqual(ts.dayofweek, 6) - self.assertTrue(isinstance(ts.dayofweek, int)) - self.assertEqual(ts.quarter, 2) - self.assertTrue(isinstance(ts.quarter, int)) - self.assertEqual(ts.dayofyear, 130) - self.assertTrue(isinstance(ts.dayofyear, int)) - self.assertEqual(ts.week, 19) - self.assertTrue(isinstance(ts.week, int)) - self.assertEqual(ts.daysinmonth, 31) - self.assertTrue(isinstance(ts.days_in_month, int)) - self.assertEqual(ts.daysinmonth, 31) - self.assertTrue(isinstance(ts.daysinmonth, int)) + check(ts.microsecond, 100) + check(ts.nanosecond, 1) + check(ts.dayofweek, 6) + check(ts.quarter, 2) + check(ts.dayofyear, 130) + check(ts.week, 19) + check(ts.daysinmonth, 31) + check(ts.daysinmonth, 31) def test_nat_fields(self): # GH 10050