summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wiebe <mwwiebe@gmail.com>2011-03-26 16:54:07 -0700
committerMark Wiebe <mwwiebe@gmail.com>2011-03-26 16:54:07 -0700
commit7d436cc8994f9efbc51289fdf6c8c520b92e179c (patch)
treebd23a5e84fcb59851d81a9aefa1b43d150d83684
parent10db2599077bda2d24d25e6aa682f6b96e339161 (diff)
downloadnumpy-7d436cc8994f9efbc51289fdf6c8c520b92e179c.tar.gz
TST: Python 2.6 doesn't implement complex.__format__, so skip the tests there
-rw-r--r--numpy/core/tests/test_print.py19
1 files changed, 13 insertions, 6 deletions
diff --git a/numpy/core/tests/test_print.py b/numpy/core/tests/test_print.py
index 16e772a8e..09b20cc3e 100644
--- a/numpy/core/tests/test_print.py
+++ b/numpy/core/tests/test_print.py
@@ -214,14 +214,21 @@ def test_scalar_format():
('{0:g}', 1.5, np.float16),
('{0:g}', 1.5, np.float32),
('{0:g}', 1.5, np.float64),
- ('{0:g}', 1.5, np.longdouble),
- ('{0:g}', 1.5+0.5j, np.complex64),
- ('{0:g}', 1.5+0.5j, np.complex128),
- ('{0:g}', 1.5+0.5j, np.clongdouble)]
+ ('{0:g}', 1.5, np.longdouble)]
+ # Python 2.6 doesn't implement complex.__format__
+ if sys.version_info <= (2,6):
+ tests += [('{0:g}', 1.5+0.5j, np.complex64),
+ ('{0:g}', 1.5+0.5j, np.complex128),
+ ('{0:g}', 1.5+0.5j, np.clongdouble)]
for (fmat, val, valtype) in tests:
- assert_equal(fmat.format(val), fmat.format(valtype(val)),
- "failed with val %s, type %s" % (val, valtype))
+ try:
+ assert_equal(fmat.format(val), fmat.format(valtype(val)),
+ "failed with val %s, type %s" % (val, valtype))
+ except ValueError, e:
+ assert_(False,
+ "format raised exception (fmt='%s', val=%s, type=%s, exc='%s')" %
+ (fmat, repr(val), repr(valtype), str(e)))
# Locale tests: scalar types formatting should be independent of the locale