summaryrefslogtreecommitdiff
path: root/babel/tests
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@gmail.com>2007-05-31 17:56:14 +0000
committerChristopher Lenz <cmlenz@gmail.com>2007-05-31 17:56:14 +0000
commit604a1bb3d6cb8f75b13cbe5603211f5cb1faefa9 (patch)
tree985c47f75740eccce98eab96343a92c82812bcaf /babel/tests
parent5033f125698bd3cde1bafd47cf3e0301bd42a660 (diff)
downloadbabel-604a1bb3d6cb8f75b13cbe5603211f5cb1faefa9.tar.gz
Moved some datetime tests from doctest to unittest, to avoid breaking docutils/epydoc doctest block detection.
Diffstat (limited to 'babel/tests')
-rw-r--r--babel/tests/dates.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/babel/tests/dates.py b/babel/tests/dates.py
index adabb9a..47616a6 100644
--- a/babel/tests/dates.py
+++ b/babel/tests/dates.py
@@ -11,7 +11,7 @@
# individuals. For the exact contribution history, see the revision
# history and logs, available at http://babel.edgewall.org/log/.
-from datetime import date, datetime
+from datetime import date, datetime, time
import doctest
import unittest
@@ -55,10 +55,36 @@ class DateTimeFormatTestCase(unittest.TestCase):
self.assertEqual('4', fmt['c']) # friday is first day of week
+class FormatDateTestCase(unittest.TestCase):
+
+ def test_with_time_fields_in_pattern(self):
+ self.assertRaises(AttributeError, dates.format_date, date(2007, 04, 01),
+ "yyyy-MM-dd HH:mm", locale='en_US')
+
+ def test_with_time_fields_in_pattern_and_datetime_param(self):
+ self.assertRaises(AttributeError, dates.format_date,
+ datetime(2007, 04, 01, 15, 30),
+ "yyyy-MM-dd HH:mm", locale='en_US')
+
+
+class FormatTimeTestCase(unittest.TestCase):
+
+ def test_with_date_fields_in_pattern(self):
+ self.assertRaises(AttributeError, dates.format_time, date(2007, 04, 01),
+ "yyyy-MM-dd HH:mm", locale='en_US')
+
+ def test_with_date_fields_in_pattern_and_datetime_param(self):
+ self.assertRaises(AttributeError, dates.format_time,
+ datetime(2007, 04, 01, 15, 30),
+ "yyyy-MM-dd HH:mm", locale='en_US')
+
+
def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(dates))
suite.addTest(unittest.makeSuite(DateTimeFormatTestCase))
+ suite.addTest(unittest.makeSuite(FormatDateTestCase))
+ suite.addTest(unittest.makeSuite(FormatTimeTestCase))
return suite
if __name__ == '__main__':