Skip to content

Commit

Permalink
Added regression test for infinity parsing in dates
Browse files Browse the repository at this point in the history
...and a couple of typos.
  • Loading branch information
dvarrazzo committed May 11, 2013
1 parent 1e94018 commit 8fd228d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,14 @@ def test_parse_negative_interval(self):
self.assertEqual(value.seconds, 41103)
self.assertEqual(value.microseconds, 876544)

def test_parse_infinity(self):
value = self.DATETIME('-infinity', self.curs)
self.assertEqual(str(value), '0001-01-01 00:00:00')
value = self.DATETIME('infinity', self.curs)
self.assertEqual(str(value), '9999-12-31 23:59:59.999999')
value = self.DATE('infinity', self.curs)
self.assertEqual(str(value), '9999-12-31')

def test_adapt_date(self):
from datetime import date
value = self.execute('select (%s)::date::text',
Expand Down Expand Up @@ -240,7 +248,7 @@ def test_adapt_timedelta(self):
self.assertEqual(seconds, 3674096)
self.assertEqual(int(round((value - seconds) * 1000000)), 123456)

def test_adapt_megative_timedelta(self):
def test_adapt_negative_timedelta(self):
from datetime import timedelta
value = self.execute('select extract(epoch from (%s)::interval)',
[timedelta(days=-42, seconds=45296,
Expand Down Expand Up @@ -428,7 +436,7 @@ def test_adapt_timedelta(self):
self.assertEqual(seconds, 3674096)
self.assertEqual(int(round((value - seconds) * 1000000)), 123456)

def test_adapt_megative_timedelta(self):
def test_adapt_negative_timedelta(self):
from mx.DateTime import DateTimeDeltaFrom
value = self.execute('select extract(epoch from (%s)::interval)',
[DateTimeDeltaFrom(days=-42,
Expand Down

0 comments on commit 8fd228d

Please sign in to comment.