summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_strftime.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-04-11 22:26:42 (GMT)
committerGuido van Rossum <guido@python.org>1997-04-11 22:26:42 (GMT)
commit62bd30c4302426f454f950cecf939c833a8f0a9b (patch)
treefe8c1b8dfd4be0f106a7267517c09717b56d928c /Lib/test/test_strftime.py
parentb31c7dcb43307b57917150d60a64856d5a845fa7 (diff)
downloadcpython-62bd30c4302426f454f950cecf939c833a8f0a9b.zip
cpython-62bd30c4302426f454f950cecf939c833a8f0a9b.tar.gz
cpython-62bd30c4302426f454f950cecf939c833a8f0a9b.tar.bz2
Catch and report ValueError raised by strftime.
Diffstat (limited to 'Lib/test/test_strftime.py')
-rwxr-xr-xLib/test/test_strftime.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py
index 6315b96..f568970 100755
--- a/Lib/test/test_strftime.py
+++ b/Lib/test/test_strftime.py
@@ -87,7 +87,11 @@ def strftest(now):
(sys.platform, string.split(sys.version)[0])
for e in expectations:
- result = time.strftime(e[0], now)
+ try:
+ result = time.strftime(e[0], now)
+ except ValueError, error:
+ print "Standard '%s' format gave error:" % e[0], error
+ continue
if result == e[1]: continue
if result[0] == '%':
print "Does not support standard '%s' format (%s)" % (e[0], e[2])
@@ -96,16 +100,24 @@ def strftest(now):
print " Expected %s, but got %s" % (e[1], result)
for e in nonstandard_expectations:
- result = time.strftime(e[0], now)
+ try:
+ result = time.strftime(e[0], now)
+ except ValueError, result:
+ if verbose:
+ print "Error for nonstandard '%s' format (%s): %s" % \
+ (e[0], e[2], str(error))
+ continue
if result == e[1]:
if verbose:
print "Supports nonstandard '%s' format (%s)" % (e[0], e[2])
elif result[0] == '%':
if verbose:
- print "Does not appear to support '%s' format" % e[0]
+ print "Does not appear to support '%s' format (%s)" % (e[0],
+ e[2])
else:
if verbose:
- print "Conflict for %s (%s):" % (e[0], e[2])
+ print "Conflict for nonstandard '%s' format (%s):" % (e[0],
+ e[2])
print " Expected %s, but got %s" % (e[1], result)
def fixasctime(s):