Mercurial > babel > old > mirror
comparison babel/tests/dates.py @ 521:e4d08b21c49b
fix expected output from !FormatTimedeltaTestCase in babel.tests.dates and ensure it will be executed during the normal test run (see #259)
author | fschwarz |
---|---|
date | Sat, 05 Mar 2011 10:22:59 +0000 |
parents | b226c4d5386e |
children | e93f68837913 |
comparison
equal
deleted
inserted
replaced
520:5dc1835664dc | 521:e4d08b21c49b |
---|---|
9 # | 9 # |
10 # This software consists of voluntary contributions made by many | 10 # This software consists of voluntary contributions made by many |
11 # individuals. For the exact contribution history, see the revision | 11 # individuals. For the exact contribution history, see the revision |
12 # history and logs, available at http://babel.edgewall.org/log/. | 12 # history and logs, available at http://babel.edgewall.org/log/. |
13 | 13 |
14 from datetime import date, datetime, time | 14 from datetime import date, datetime, time, timedelta |
15 import doctest | 15 import doctest |
16 import new | 16 import new |
17 import unittest | 17 import unittest |
18 | 18 |
19 from pytz import timezone | 19 from pytz import timezone |
251 | 251 |
252 class FormatTimedeltaTestCase(unittest.TestCase): | 252 class FormatTimedeltaTestCase(unittest.TestCase): |
253 | 253 |
254 def test_zero_seconds(self): | 254 def test_zero_seconds(self): |
255 string = dates.format_timedelta(timedelta(seconds=0), locale='en') | 255 string = dates.format_timedelta(timedelta(seconds=0), locale='en') |
256 self.assertEqual('0 seconds', string) | 256 self.assertEqual('0 secs', string) |
257 string = dates.format_timedelta(timedelta(seconds=0), | 257 string = dates.format_timedelta(timedelta(seconds=0), |
258 granularity='hour', locale='en') | 258 granularity='hour', locale='en') |
259 self.assertEqual('0 hours', string) | 259 self.assertEqual('0 hrs', string) |
260 | 260 |
261 def test_small_value_with_granularity(self): | 261 def test_small_value_with_granularity(self): |
262 string = dates.format_timedelta(timedelta(seconds=42), | 262 string = dates.format_timedelta(timedelta(seconds=42), |
263 granularity='hour', locale='en') | 263 granularity='hour', locale='en') |
264 self.assertEqual('1 hour', string) | 264 self.assertEqual('1 hr', string) |
265 | 265 |
266 | 266 |
267 class TimeZoneAdjustTestCase(unittest.TestCase): | 267 class TimeZoneAdjustTestCase(unittest.TestCase): |
268 def _utc(self): | 268 def _utc(self): |
269 UTC = FixedOffsetTimezone(0, 'UTC') | 269 UTC = FixedOffsetTimezone(0, 'UTC') |
286 suite = unittest.TestSuite() | 286 suite = unittest.TestSuite() |
287 suite.addTest(doctest.DocTestSuite(dates)) | 287 suite.addTest(doctest.DocTestSuite(dates)) |
288 suite.addTest(unittest.makeSuite(DateTimeFormatTestCase)) | 288 suite.addTest(unittest.makeSuite(DateTimeFormatTestCase)) |
289 suite.addTest(unittest.makeSuite(FormatDateTestCase)) | 289 suite.addTest(unittest.makeSuite(FormatDateTestCase)) |
290 suite.addTest(unittest.makeSuite(FormatTimeTestCase)) | 290 suite.addTest(unittest.makeSuite(FormatTimeTestCase)) |
291 suite.addTest(unittest.makeSuite(FormatTimedeltaTestCase)) | |
291 suite.addTest(unittest.makeSuite(TimeZoneAdjustTestCase)) | 292 suite.addTest(unittest.makeSuite(TimeZoneAdjustTestCase)) |
292 return suite | 293 return suite |
293 | 294 |
294 | 295 |
295 if __name__ == '__main__': | 296 if __name__ == '__main__': |