From 7d436cc8994f9efbc51289fdf6c8c520b92e179c Mon Sep 17 00:00:00 2001 From: Mark Wiebe Date: Sat, 26 Mar 2011 16:54:07 -0700 Subject: TST: Python 2.6 doesn't implement complex.__format__, so skip the tests there --- numpy/core/tests/test_print.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'numpy') 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 -- cgit v1.2.1