Pure Python strptime implementation by Brett Cannon. See SF patch 474274.

Also adds tests.
This commit is contained in:
Guido van Rossum 2002-07-19 17:04:46 +00:00
parent 206d8f818f
commit 00efe7e798
3 changed files with 779 additions and 0 deletions

View file

@ -37,6 +37,18 @@ class TimeTestCase(unittest.TestCase):
except ValueError:
self.fail('conversion specifier: %r failed.' % format)
def test_strptime(self):
tt = time.gmtime(self.t)
for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I',
'j', 'm', 'M', 'p', 'S',
'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'):
format = ' %' + directive
try:
time.strptime(time.strftime(format, tt), format)
except ValueError:
self.fail('conversion specifier: %r failed.' % format)
def test_asctime(self):
time.asctime(time.gmtime(self.t))
self.assertRaises(TypeError, time.asctime, 0)