comparison test/test_dates.py @ 5036:380d8d8b30a3

Replace existing run_tests.py script with a pytest script The existing run_test.py script is quite old, a bit restrictive, and doesn't always behave as documented. The pytest testing tool is mature, well documented, and maintained. The run_tests.py script is generating by installing py.test and running: py.tests --genscript=run_tests.py Note: to generate a script that is compatible with python2.6 the command needs to be run using python2.6
author John Kristensen <john@jerrykan.com>
date Thu, 20 Aug 2015 18:15:23 +1000
parents 9cc6d463cfbe
children 364c54991861
comparison
equal deleted inserted replaced
5035:b5bb492e4b3c 5036:380d8d8b30a3
18 import unittest 18 import unittest
19 import time 19 import time
20 import datetime 20 import datetime
21 import calendar 21 import calendar
22 22
23 import pytest
23 from roundup import date, i18n 24 from roundup import date, i18n
24 from roundup.date import Date, Interval, Range, fixTimeOverflow, \ 25 from roundup.date import Date, Interval, Range, fixTimeOverflow, \
25 get_timezone 26 get_timezone
27
28 try:
29 import pytz
30 SKIP_PYTZ = False
31 except ImportError:
32 SKIP_PYTZ = True
33
34 skip_pytz = pytest.mark.skipif(SKIP_PYTZ, reason="'pytz' not installed")
26 35
27 36
28 class DateTestCase(unittest.TestCase): 37 class DateTestCase(unittest.TestCase):
29 def setUp(self): 38 def setUp(self):
30 self.old_gettext_ = i18n.gettext 39 self.old_gettext_ = i18n.gettext
450 ae (date.timestamp(), 253370764800.0) 459 ae (date.timestamp(), 253370764800.0)
451 date = Date('0033') 460 date = Date('0033')
452 ae (date.timestamp(), -61125753600.0) 461 ae (date.timestamp(), -61125753600.0)
453 ae(str(date), '0033-01-01.00:00:00') 462 ae(str(date), '0033-01-01.00:00:00')
454 463
464
465 @skip_pytz
455 class TimezoneTestCase(unittest.TestCase): 466 class TimezoneTestCase(unittest.TestCase):
456 467
457 def testTZ(self): 468 def testTZ(self):
458 ae = self.assertEqual 469 ae = self.assertEqual
459 tz = 'Europe/Warsaw' 470 tz = 'Europe/Warsaw'

Roundup Issue Tracker: http://roundup-tracker.org/