annotate 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
rev   line source
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
2 #
14
29ef15a6fd75 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents: 3
diff changeset
3 # Copyright (C) 2007 Edgewall Software
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
4 # All rights reserved.
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
5 #
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
8 # are also available at http://babel.edgewall.org/wiki/License.
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
9 #
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
12 # history and logs, available at http://babel.edgewall.org/log/.
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
13
521
e4d08b21c49b fix expected output from !FormatTimedeltaTestCase in babel.tests.dates and ensure it will be executed during the normal test run (see #259)
fschwarz
parents: 514
diff changeset
14 from datetime import date, datetime, time, timedelta
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
15 import doctest
514
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
16 import new
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
17 import unittest
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
18
31
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
19 from pytz import timezone
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
20
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
21 from babel import dates
514
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
22 from babel.util import FixedOffsetTimezone
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
23
17
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
24
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
25 class DateTimeFormatTestCase(unittest.TestCase):
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
26
398
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
27 def test_quarter_format(self):
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
28 d = date(2006, 6, 8)
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
29 fmt = dates.DateTimeFormat(d, locale='en_US')
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
30 self.assertEqual('2', fmt['Q'])
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
31 self.assertEqual('2nd quarter', fmt['QQQQ'])
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
32 d = date(2006, 12, 31)
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
33 fmt = dates.DateTimeFormat(d, locale='en_US')
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
34 self.assertEqual('Q4', fmt['QQQ'])
c37bc86b4e3a Fixed quarters in date formatting.
cmlenz
parents: 397
diff changeset
35
346
36c243367cc9 Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to Andrew Stromnov for reporting the problem and providing a patch.
cmlenz
parents: 276
diff changeset
36 def test_month_context(self):
36c243367cc9 Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to Andrew Stromnov for reporting the problem and providing a patch.
cmlenz
parents: 276
diff changeset
37 d = date(2006, 1, 8)
36c243367cc9 Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to Andrew Stromnov for reporting the problem and providing a patch.
cmlenz
parents: 276
diff changeset
38 fmt = dates.DateTimeFormat(d, locale='cs_CZ')
36c243367cc9 Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to Andrew Stromnov for reporting the problem and providing a patch.
cmlenz
parents: 276
diff changeset
39 self.assertEqual('1', fmt['MMM'])
36c243367cc9 Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to Andrew Stromnov for reporting the problem and providing a patch.
cmlenz
parents: 276
diff changeset
40 fmt = dates.DateTimeFormat(d, locale='cs_CZ')
36c243367cc9 Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to Andrew Stromnov for reporting the problem and providing a patch.
cmlenz
parents: 276
diff changeset
41 self.assertEqual('1.', fmt['LLL'])
36c243367cc9 Fix for incorrect month context lookup in date formatting. Closes #75. Thanks to Andrew Stromnov for reporting the problem and providing a patch.
cmlenz
parents: 276
diff changeset
42
377
841858d5b567 Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents: 350
diff changeset
43 def test_abbreviated_month_alias(self):
841858d5b567 Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents: 350
diff changeset
44 d = date(2006, 3, 8)
841858d5b567 Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents: 350
diff changeset
45 fmt = dates.DateTimeFormat(d, locale='de_DE')
841858d5b567 Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents: 350
diff changeset
46 self.assertEqual(u'Mär', fmt['LLL'])
841858d5b567 Implement support for aliases in the CLDR data. Closes #68. Also, update to CLDR 1.6, and a much improved `dump_data` script.
cmlenz
parents: 350
diff changeset
47
242
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
48 def test_week_of_year_first(self):
241
be0a3606471f Again, properly implement week-in-year (#46).
cmlenz
parents: 240
diff changeset
49 d = date(2006, 1, 8)
be0a3606471f Again, properly implement week-in-year (#46).
cmlenz
parents: 240
diff changeset
50 fmt = dates.DateTimeFormat(d, locale='de_DE')
be0a3606471f Again, properly implement week-in-year (#46).
cmlenz
parents: 240
diff changeset
51 self.assertEqual('1', fmt['w'])
217
15ac328954f5 Dummy/stub implementation for week-in-year and week-in-month date format fields. Also, treat extended year the same as the regular year field, not even ICU seems to handle it specially.
cmlenz
parents: 131
diff changeset
52 fmt = dates.DateTimeFormat(d, locale='en_US')
241
be0a3606471f Again, properly implement week-in-year (#46).
cmlenz
parents: 240
diff changeset
53 self.assertEqual('02', fmt['ww'])
217
15ac328954f5 Dummy/stub implementation for week-in-year and week-in-month date format fields. Also, treat extended year the same as the regular year field, not even ICU seems to handle it specially.
cmlenz
parents: 131
diff changeset
54
244
cfb4cb07cbc7 Finish implementation of day-of-year and day-of-month for now, and fix implementation of year-of-week-of-year field. Closes #46. I suspect there are still cases not entirely covered by this implementation, but those can be filed as separate tickets.
cmlenz
parents: 243
diff changeset
55 def test_week_of_year_first_with_year(self):
cfb4cb07cbc7 Finish implementation of day-of-year and day-of-month for now, and fix implementation of year-of-week-of-year field. Closes #46. I suspect there are still cases not entirely covered by this implementation, but those can be filed as separate tickets.
cmlenz
parents: 243
diff changeset
56 d = date(2006, 1, 1)
cfb4cb07cbc7 Finish implementation of day-of-year and day-of-month for now, and fix implementation of year-of-week-of-year field. Closes #46. I suspect there are still cases not entirely covered by this implementation, but those can be filed as separate tickets.
cmlenz
parents: 243
diff changeset
57 fmt = dates.DateTimeFormat(d, locale='de_DE')
cfb4cb07cbc7 Finish implementation of day-of-year and day-of-month for now, and fix implementation of year-of-week-of-year field. Closes #46. I suspect there are still cases not entirely covered by this implementation, but those can be filed as separate tickets.
cmlenz
parents: 243
diff changeset
58 self.assertEqual('52', fmt['w'])
cfb4cb07cbc7 Finish implementation of day-of-year and day-of-month for now, and fix implementation of year-of-week-of-year field. Closes #46. I suspect there are still cases not entirely covered by this implementation, but those can be filed as separate tickets.
cmlenz
parents: 243
diff changeset
59 self.assertEqual('2005', fmt['YYYY'])
cfb4cb07cbc7 Finish implementation of day-of-year and day-of-month for now, and fix implementation of year-of-week-of-year field. Closes #46. I suspect there are still cases not entirely covered by this implementation, but those can be filed as separate tickets.
cmlenz
parents: 243
diff changeset
60
242
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
61 def test_week_of_year_last(self):
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
62 d = date(2005, 12, 26)
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
63 fmt = dates.DateTimeFormat(d, locale='de_DE')
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
64 self.assertEqual('52', fmt['w'])
217
15ac328954f5 Dummy/stub implementation for week-in-year and week-in-month date format fields. Also, treat extended year the same as the regular year field, not even ICU seems to handle it specially.
cmlenz
parents: 131
diff changeset
65 fmt = dates.DateTimeFormat(d, locale='en_US')
440
a3ddb13ff2a6 The date now returns 52 with the current data, adjust the test accordingly.
jruigrok
parents: 432
diff changeset
66 self.assertEqual('52', fmt['ww'])
242
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
67
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
68 def test_week_of_month_first(self):
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
69 d = date(2006, 1, 8)
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
70 fmt = dates.DateTimeFormat(d, locale='de_DE')
217
15ac328954f5 Dummy/stub implementation for week-in-year and week-in-month date format fields. Also, treat extended year the same as the regular year field, not even ICU seems to handle it specially.
cmlenz
parents: 131
diff changeset
71 self.assertEqual('1', fmt['W'])
242
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
72 fmt = dates.DateTimeFormat(d, locale='en_US')
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
73 self.assertEqual('2', fmt['W'])
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
74
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
75 def test_week_of_month_last(self):
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
76 d = date(2006, 1, 29)
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
77 fmt = dates.DateTimeFormat(d, locale='de_DE')
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
78 self.assertEqual('4', fmt['W'])
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
79 fmt = dates.DateTimeFormat(d, locale='en_US')
9b13c9a436c5 More work on #46 (week-of-year/week-of-month).
cmlenz
parents: 241
diff changeset
80 self.assertEqual('5', fmt['W'])
217
15ac328954f5 Dummy/stub implementation for week-in-year and week-in-month date format fields. Also, treat extended year the same as the regular year field, not even ICU seems to handle it specially.
cmlenz
parents: 131
diff changeset
81
223
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
82 def test_day_of_year(self):
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
83 d = date(2007, 4, 1)
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
84 fmt = dates.DateTimeFormat(d, locale='en_US')
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
85 self.assertEqual('91', fmt['D'])
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
86
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
87 def test_day_of_year_first(self):
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
88 d = date(2007, 1, 1)
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
89 fmt = dates.DateTimeFormat(d, locale='en_US')
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
90 self.assertEqual('001', fmt['DDD'])
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
91
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
92 def test_day_of_year_last(self):
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
93 d = date(2007, 12, 31)
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
94 fmt = dates.DateTimeFormat(d, locale='en_US')
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
95 self.assertEqual('365', fmt['DDD'])
49b089453f81 Implement day-of-year date format field. Closes #49.
cmlenz
parents: 219
diff changeset
96
243
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
97 def test_day_of_week_in_month(self):
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
98 d = date(2007, 4, 15)
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
99 fmt = dates.DateTimeFormat(d, locale='en_US')
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
100 self.assertEqual('3', fmt['F'])
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
101
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
102 def test_day_of_week_in_month_first(self):
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
103 d = date(2007, 4, 1)
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
104 fmt = dates.DateTimeFormat(d, locale='en_US')
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
105 self.assertEqual('1', fmt['F'])
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
106
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
107 def test_day_of_week_in_month_last(self):
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
108 d = date(2007, 4, 29)
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
109 fmt = dates.DateTimeFormat(d, locale='en_US')
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
110 self.assertEqual('5', fmt['F'])
2ed73d964211 Implement day-of-week-in-month field in date formatting. Closes #50.
cmlenz
parents: 242
diff changeset
111
17
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
112 def test_local_day_of_week(self):
219
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
113 d = date(2007, 4, 1) # a sunday
17
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
114 fmt = dates.DateTimeFormat(d, locale='de_DE')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
115 self.assertEqual('7', fmt['e']) # monday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
116 fmt = dates.DateTimeFormat(d, locale='en_US')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
117 self.assertEqual('01', fmt['ee']) # sunday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
118 fmt = dates.DateTimeFormat(d, locale='dv_MV')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
119 self.assertEqual('03', fmt['ee']) # friday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
120
219
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
121 d = date(2007, 4, 2) # a monday
17
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
122 fmt = dates.DateTimeFormat(d, locale='de_DE')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
123 self.assertEqual('1', fmt['e']) # monday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
124 fmt = dates.DateTimeFormat(d, locale='en_US')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
125 self.assertEqual('02', fmt['ee']) # sunday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
126 fmt = dates.DateTimeFormat(d, locale='dv_MV')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
127 self.assertEqual('04', fmt['ee']) # friday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
128
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
129 def test_local_day_of_week_standalone(self):
219
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
130 d = date(2007, 4, 1) # a sunday
17
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
131 fmt = dates.DateTimeFormat(d, locale='de_DE')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
132 self.assertEqual('7', fmt['c']) # monday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
133 fmt = dates.DateTimeFormat(d, locale='en_US')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
134 self.assertEqual('1', fmt['c']) # sunday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
135 fmt = dates.DateTimeFormat(d, locale='dv_MV')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
136 self.assertEqual('3', fmt['c']) # friday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
137
219
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
138 d = date(2007, 4, 2) # a monday
17
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
139 fmt = dates.DateTimeFormat(d, locale='de_DE')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
140 self.assertEqual('1', fmt['c']) # monday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
141 fmt = dates.DateTimeFormat(d, locale='en_US')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
142 self.assertEqual('2', fmt['c']) # sunday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
143 fmt = dates.DateTimeFormat(d, locale='dv_MV')
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
144 self.assertEqual('4', fmt['c']) # friday is first day of week
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
145
218
0a30f3974997 Support for fractional seconds field in date formatting. Closes #47.
cmlenz
parents: 217
diff changeset
146 def test_fractional_seconds(self):
219
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
147 t = time(15, 30, 12, 34567)
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
148 fmt = dates.DateTimeFormat(t, locale='en_US')
218
0a30f3974997 Support for fractional seconds field in date formatting. Closes #47.
cmlenz
parents: 217
diff changeset
149 self.assertEqual('3457', fmt['SSSS'])
0a30f3974997 Support for fractional seconds field in date formatting. Closes #47.
cmlenz
parents: 217
diff changeset
150
0a30f3974997 Support for fractional seconds field in date formatting. Closes #47.
cmlenz
parents: 217
diff changeset
151 def test_fractional_seconds_zero(self):
219
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
152 t = time(15, 30, 0)
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
153 fmt = dates.DateTimeFormat(t, locale='en_US')
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
154 self.assertEqual('0000', fmt['SSSS'])
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
155
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
156 def test_milliseconds_in_day(self):
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
157 t = time(15, 30, 12, 345000)
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
158 fmt = dates.DateTimeFormat(t, locale='en_US')
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
159 self.assertEqual('55812345', fmt['AAAA'])
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
160
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
161 def test_milliseconds_in_day_zero(self):
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
162 d = time(0, 0, 0)
218
0a30f3974997 Support for fractional seconds field in date formatting. Closes #47.
cmlenz
parents: 217
diff changeset
163 fmt = dates.DateTimeFormat(d, locale='en_US')
219
f065fb523fd6 Implement milliseconds in day (#48).
cmlenz
parents: 218
diff changeset
164 self.assertEqual('0000', fmt['AAAA'])
218
0a30f3974997 Support for fractional seconds field in date formatting. Closes #47.
cmlenz
parents: 217
diff changeset
165
31
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
166 def test_timezone_rfc822(self):
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
167 tz = timezone('Europe/Berlin')
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
168 t = time(15, 30, tzinfo=tz)
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
169 fmt = dates.DateTimeFormat(t, locale='de_DE')
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
170 self.assertEqual('+0100', fmt['Z'])
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
171
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
172 def test_timezone_gmt(self):
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
173 tz = timezone('Europe/Berlin')
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
174 t = time(15, 30, tzinfo=tz)
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
175 fmt = dates.DateTimeFormat(t, locale='de_DE')
235
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
176 self.assertEqual('GMT+01:00', fmt['ZZZZ'])
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
177
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
178 def test_timezone_no_uncommon(self):
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
179 tz = timezone('Europe/Paris')
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
180 dt = datetime(2007, 4, 1, 15, 30, tzinfo=tz)
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
181 fmt = dates.DateTimeFormat(dt, locale='fr_CA')
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
182 self.assertEqual('France', fmt['v'])
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
183
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
184 def test_timezone_with_uncommon(self):
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
185 tz = timezone('Europe/Paris')
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
186 dt = datetime(2007, 4, 1, 15, 30, tzinfo=tz)
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
187 fmt = dates.DateTimeFormat(dt, locale='fr_CA')
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
188 self.assertEqual('HEC', fmt['V'])
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
189
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
190 def test_timezone_location_format(self):
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
191 tz = timezone('Europe/Paris')
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
192 dt = datetime(2007, 4, 1, 15, 30, tzinfo=tz)
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
193 fmt = dates.DateTimeFormat(dt, locale='fr_FR')
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
194 self.assertEqual('France', fmt['VVVV'])
31
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
195
131
669a9b3a24ad Implement wall-time time-zone display.
cmlenz
parents: 31
diff changeset
196 def test_timezone_walltime_short(self):
669a9b3a24ad Implement wall-time time-zone display.
cmlenz
parents: 31
diff changeset
197 tz = timezone('Europe/Paris')
669a9b3a24ad Implement wall-time time-zone display.
cmlenz
parents: 31
diff changeset
198 t = time(15, 30, tzinfo=tz)
235
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
199 fmt = dates.DateTimeFormat(t, locale='fr_FR')
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
200 self.assertEqual('HEC', fmt['v'])
131
669a9b3a24ad Implement wall-time time-zone display.
cmlenz
parents: 31
diff changeset
201
669a9b3a24ad Implement wall-time time-zone display.
cmlenz
parents: 31
diff changeset
202 def test_timezone_walltime_long(self):
669a9b3a24ad Implement wall-time time-zone display.
cmlenz
parents: 31
diff changeset
203 tz = timezone('Europe/Paris')
669a9b3a24ad Implement wall-time time-zone display.
cmlenz
parents: 31
diff changeset
204 t = time(15, 30, tzinfo=tz)
235
d0cd235ede46 Upgraded to CLDR 1.5 and improved timezone formatting.
cmlenz
parents: 223
diff changeset
205 fmt = dates.DateTimeFormat(t, locale='fr_FR')
432
b4f01db57a9e First changes to accomodate CLDR 1.7's changes.
jruigrok
parents: 398
diff changeset
206 self.assertEqual(u'Heure de l\u2019Europe centrale', fmt['vvvv'])
31
3956bb7ff93b More work on timezones.
cmlenz
parents: 21
diff changeset
207
275
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
208 def test_hour_formatting(self):
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
209 l = 'en_US'
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
210 t = time(0, 0, 0)
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
211 self.assertEqual(dates.format_time(t, 'h a', locale=l), '12 AM')
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
212 self.assertEqual(dates.format_time(t, 'H', locale=l), '0')
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
213 self.assertEqual(dates.format_time(t, 'k', locale=l), '24')
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
214 self.assertEqual(dates.format_time(t, 'K a', locale=l), '0 AM')
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
215 t = time(12, 0, 0)
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
216 self.assertEqual(dates.format_time(t, 'h a', locale=l), '12 PM')
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
217 self.assertEqual(dates.format_time(t, 'H', locale=l), '12')
276
a0309405feee Fixed a bug introduced by [301].
jonas
parents: 275
diff changeset
218 self.assertEqual(dates.format_time(t, 'k', locale=l), '12')
275
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
219 self.assertEqual(dates.format_time(t, 'K a', locale=l), '0 PM')
cd2d75cf4b43 Fixed formatting bug with 12-hour clock patterns.
jonas
parents: 244
diff changeset
220
17
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
221
21
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
222 class FormatDateTestCase(unittest.TestCase):
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
223
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
224 def test_with_time_fields_in_pattern(self):
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
225 self.assertRaises(AttributeError, dates.format_date, date(2007, 04, 01),
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
226 "yyyy-MM-dd HH:mm", locale='en_US')
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
227
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
228 def test_with_time_fields_in_pattern_and_datetime_param(self):
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
229 self.assertRaises(AttributeError, dates.format_date,
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
230 datetime(2007, 04, 01, 15, 30),
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
231 "yyyy-MM-dd HH:mm", locale='en_US')
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
232
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
233
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
234 class FormatTimeTestCase(unittest.TestCase):
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
235
350
e5db561bf70e Fixes for timezone calculations in time formatting (#83).
cmlenz
parents: 346
diff changeset
236 def test_with_naive_datetime_and_tzinfo(self):
e5db561bf70e Fixes for timezone calculations in time formatting (#83).
cmlenz
parents: 346
diff changeset
237 string = dates.format_time(datetime(2007, 4, 1, 15, 30),
e5db561bf70e Fixes for timezone calculations in time formatting (#83).
cmlenz
parents: 346
diff changeset
238 'long', tzinfo=timezone('US/Eastern'),
e5db561bf70e Fixes for timezone calculations in time formatting (#83).
cmlenz
parents: 346
diff changeset
239 locale='en')
e5db561bf70e Fixes for timezone calculations in time formatting (#83).
cmlenz
parents: 346
diff changeset
240 self.assertEqual('11:30:00 AM EDT', string)
e5db561bf70e Fixes for timezone calculations in time formatting (#83).
cmlenz
parents: 346
diff changeset
241
21
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
242 def test_with_date_fields_in_pattern(self):
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
243 self.assertRaises(AttributeError, dates.format_time, date(2007, 04, 01),
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
244 "yyyy-MM-dd HH:mm", locale='en_US')
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
245
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
246 def test_with_date_fields_in_pattern_and_datetime_param(self):
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
247 self.assertRaises(AttributeError, dates.format_time,
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
248 datetime(2007, 04, 01, 15, 30),
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
249 "yyyy-MM-dd HH:mm", locale='en_US')
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
250
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
251
397
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
252 class FormatTimedeltaTestCase(unittest.TestCase):
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
253
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
254 def test_zero_seconds(self):
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
255 string = dates.format_timedelta(timedelta(seconds=0), locale='en')
521
e4d08b21c49b fix expected output from !FormatTimedeltaTestCase in babel.tests.dates and ensure it will be executed during the normal test run (see #259)
fschwarz
parents: 514
diff changeset
256 self.assertEqual('0 secs', string)
397
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
257 string = dates.format_timedelta(timedelta(seconds=0),
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
258 granularity='hour', locale='en')
521
e4d08b21c49b fix expected output from !FormatTimedeltaTestCase in babel.tests.dates and ensure it will be executed during the normal test run (see #259)
fschwarz
parents: 514
diff changeset
259 self.assertEqual('0 hrs', string)
397
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
260
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
261 def test_small_value_with_granularity(self):
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
262 string = dates.format_timedelta(timedelta(seconds=42),
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
263 granularity='hour', locale='en')
521
e4d08b21c49b fix expected output from !FormatTimedeltaTestCase in babel.tests.dates and ensure it will be executed during the normal test run (see #259)
fschwarz
parents: 514
diff changeset
264 self.assertEqual('1 hr', string)
397
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
265
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
266
514
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
267 class TimeZoneAdjustTestCase(unittest.TestCase):
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
268 def _utc(self):
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
269 UTC = FixedOffsetTimezone(0, 'UTC')
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
270 def fake_localize(self, dt, is_dst=False):
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
271 raise NotImplementedError()
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
272 UTC.localize = new.instancemethod(fake_localize, UTC, UTC.__class__)
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
273 # This is important to trigger the actual bug (#257)
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
274 self.assertEqual(False, hasattr(UTC, 'normalize'))
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
275 return UTC
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
276
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
277 def test_can_format_time_with_non_pytz_timezone(self):
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
278 # regression test for #257
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
279 utc = self._utc()
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
280 t = datetime(2007, 4, 1, 15, 30, tzinfo=utc)
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
281 formatted_time = dates.format_time(t, 'long', tzinfo=utc, locale='en')
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
282 self.assertEqual('3:30:00 PM +0000', formatted_time)
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
283
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
284
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
285 def suite():
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
286 suite = unittest.TestSuite()
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
287 suite.addTest(doctest.DocTestSuite(dates))
17
aa33ad077d24 Minor date formatting improvements.
cmlenz
parents: 14
diff changeset
288 suite.addTest(unittest.makeSuite(DateTimeFormatTestCase))
21
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
289 suite.addTest(unittest.makeSuite(FormatDateTestCase))
646f3f7e6a9a Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
cmlenz
parents: 18
diff changeset
290 suite.addTest(unittest.makeSuite(FormatTimeTestCase))
521
e4d08b21c49b fix expected output from !FormatTimedeltaTestCase in babel.tests.dates and ensure it will be executed during the normal test run (see #259)
fschwarz
parents: 514
diff changeset
291 suite.addTest(unittest.makeSuite(FormatTimedeltaTestCase))
514
b226c4d5386e add tests from r563 to trunk
fschwarz
parents: 440
diff changeset
292 suite.addTest(unittest.makeSuite(TimeZoneAdjustTestCase))
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
293 return suite
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
294
397
ff9a6a37eb72 The `format_timedelta` function now returns, for example, ?1 day? instead of ?0 days? if the granularity is `day` and the delta is less than a day but greater than zero.
cmlenz
parents: 377
diff changeset
295
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
296 if __name__ == '__main__':
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
297 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software