diff options
author | Georg Brandl <georg@python.org> | 2011-01-02 22:33:43 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2011-01-02 22:33:43 (GMT) |
commit | e10608cf5de214985308a8d9eb6ace07bc9c590e (patch) | |
tree | c98ff816df5594b3c64311a0740184c75dfb1832 /Lib/test/test_time.py | |
parent | 3e913c9ecf5fc7e4a0daea116ac73d3fae4ab84c (diff) | |
download | cpython-e10608cf5de214985308a8d9eb6ace07bc9c590e.zip cpython-e10608cf5de214985308a8d9eb6ace07bc9c590e.tar.gz cpython-e10608cf5de214985308a8d9eb6ace07bc9c590e.tar.bz2 |
#8013 follow-up:
* In asctime and ctime, properly remove the newline if the year has more than four digits
* Consistent error message for both functions
* Fix the test comments and add a check for the removed newline
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r-- | Lib/test/test_time.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index 5d2ae42..6451b27 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -123,19 +123,33 @@ class TimeTestCase(unittest.TestCase): time.asctime(time.gmtime(self.t)) self.assertRaises(TypeError, time.asctime, 0) self.assertRaises(TypeError, time.asctime, ()) - # XXX: Posix compiant asctime should refuse to convert - # year > 9999, but Linux implementation does not. - # self.assertRaises(ValueError, time.asctime, - # (12345, 1, 0, 0, 0, 0, 0, 0, 0)) - # XXX: For now, just make sure we don't have a crash: + # XXX: POSIX-compliant asctime should refuse to convert year > 9999, + # but glibc implementation does not. For now, just check it doesn't + # segfault as it did before, and the result contains no newline. try: - time.asctime((12345, 1, 0, 0, 0, 0, 0, 0, 0)) + result = time.asctime((12345, 1, 0, 0, 0, 0, 0, 0, 0)) except ValueError: + # for POSIX-compliant runtimes pass + else: + self.assertNotIn('\n', result) def test_asctime_bounding_check(self): self._bounds_checking(time.asctime) + def test_ctime(self): + # XXX: POSIX-compliant ctime should refuse to convert year > 9999, + # but glibc implementation does not. For now, just check it doesn't + # segfault as it did before, and the result contains no newline. + try: + result = time.ctime(1e12) + except ValueError: + # for POSIX-compliant runtimes (or 32-bit systems, where time_t + # cannot hold timestamps with a five-digit year) + pass + else: + self.assertNotIn('\n', result) + @unittest.skipIf(not hasattr(time, "tzset"), "time module has no attribute tzset") def test_tzset(self): |