Skip to content

Commit

Permalink
TST: windows tests for allow for int/long #10050
Browse files Browse the repository at this point in the history
  • Loading branch information
jreback committed May 15, 2015
1 parent 91ddf3c commit 2bab718
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 39 deletions.
26 changes: 15 additions & 11 deletions pandas/tseries/tests/test_timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'))
Expand Down Expand Up @@ -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)
Expand Down
48 changes: 20 additions & 28 deletions pandas/tseries/tests/test_tslib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2bab718

Please sign in to comment.