Changeset 8185 for main/waeup.kofa/trunk/src/waeup/kofa/utils/tests
- Timestamp:
- 16 Apr 2012, 23:17:35 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_helpers.py
r7942 r8185 19 19 ## 20 20 21 import datetime 21 22 import os 23 import pytz 22 24 import shutil 23 25 import tempfile … … 262 264 self.assertEqual(sorted(result5), ['baz']) 263 265 return 266 267 class DateTimeHelpersTestCase(unittest.TestCase): 268 269 def test_now(self): 270 tz_berlin = pytz.timezone('Europe/Berlin') 271 result1 = helpers.now() 272 result2 = helpers.now(tz_berlin) 273 self.assertEqual(result1.tzinfo, pytz.utc) 274 self.assertFalse(result2.tzinfo == pytz.utc) 275 self.assertFalse(result2.tzinfo is None) 276 return 277 278 def test_to_timezone(self): 279 fmt = '%Y-%m-%d %H:%M:%S %Z%z' 280 tz_berlin = pytz.timezone('Europe/Berlin') 281 tz_lagos = pytz.timezone('Africa/Lagos') 282 dt1 = datetime.datetime(2012, 1, 1, 0, 0) 283 dt2 = datetime.datetime(2012, 1, 1, 0, 0, tzinfo=tz_berlin) 284 dt3 = datetime.datetime(2012, 6, 1, 0, 0, tzinfo=tz_lagos) 285 dt4 = datetime.datetime(2012, 6, 1, 0, 0, tzinfo=tz_berlin) 286 result1 = helpers.to_timezone(dt1) 287 result2 = helpers.to_timezone(dt1, pytz.utc) 288 result3 = helpers.to_timezone(dt2) 289 result4 = helpers.to_timezone(dt2, tz_lagos) 290 result5 = helpers.to_timezone(dt3, tz_berlin) 291 result6 = helpers.to_timezone(dt4, tz_lagos) 292 self.assertEqual( 293 result1.strftime(fmt), '2012-01-01 00:00:00 UTC+0000') 294 self.assertEqual( 295 result2.strftime(fmt), '2012-01-01 00:00:00 UTC+0000') 296 self.assertEqual( 297 result3.strftime(fmt), '2011-12-31 23:00:00 UTC+0000') 298 self.assertEqual( 299 result4.strftime(fmt), '2012-01-01 00:00:00 WAT+0100') 300 self.assertEqual( 301 result5.strftime(fmt), '2012-06-01 01:46:00 CEST+0200') 302 self.assertEqual( 303 result6.strftime(fmt), '2012-06-01 00:00:00 WAT+0100') 304 return 305 264 306 265 307 def test_suite(): … … 275 317 FileSizeTestCase, 276 318 IfaceNamesTestCase, 319 DateTimeHelpersTestCase, 277 320 ]: 278 321 suite.addTests(
Note: See TracChangeset for help on using the changeset viewer.