From fde54350a8d740308d12c2ea4c65fa5bea4f186a Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 8 Jun 2017 14:00:57 +1000 Subject: [PATCH] tests/float: Convert "sys.exit()" to "raise SystemExit". The latter is shorter and simpler because it doesn't require importing the sys module. --- tests/float/array_construct.py | 3 +-- tests/float/builtin_float_minmax.py | 3 +-- tests/float/bytearray_construct.py | 3 +-- tests/float/bytes_construct.py | 3 +-- tests/float/cmath_fun.py | 3 +-- tests/float/cmath_fun_special.py | 3 +-- tests/float/float_array.py | 3 +-- tests/float/float_struct.py | 3 +-- tests/float/math_fun.py | 3 +-- tests/float/math_fun_bool.py | 3 +-- tests/float/math_fun_int.py | 3 +-- tests/float/math_fun_intbig.py | 3 +-- tests/float/math_fun_special.py | 3 +-- 13 files changed, 13 insertions(+), 26 deletions(-) diff --git a/tests/float/array_construct.py b/tests/float/array_construct.py index 7e01fd4768..938675835b 100644 --- a/tests/float/array_construct.py +++ b/tests/float/array_construct.py @@ -3,9 +3,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(array('f', array('h', [1, 2]))) print(array('d', array('f', [1, 2]))) diff --git a/tests/float/builtin_float_minmax.py b/tests/float/builtin_float_minmax.py index 42cfa63822..20ad3ddf49 100644 --- a/tests/float/builtin_float_minmax.py +++ b/tests/float/builtin_float_minmax.py @@ -3,9 +3,8 @@ try: min max except: - import sys print("SKIP") - sys.exit() + raise SystemExit print(min(0,1.0)) print(min(1.0,0)) diff --git a/tests/float/bytearray_construct.py b/tests/float/bytearray_construct.py index db946a99d3..e960d624ec 100644 --- a/tests/float/bytearray_construct.py +++ b/tests/float/bytearray_construct.py @@ -3,8 +3,7 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(bytearray(array('f', [1, 2.3]))) diff --git a/tests/float/bytes_construct.py b/tests/float/bytes_construct.py index 8664d7296d..0e4482e436 100644 --- a/tests/float/bytes_construct.py +++ b/tests/float/bytes_construct.py @@ -3,8 +3,7 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit print(bytes(array('f', [1, 2.3]))) diff --git a/tests/float/cmath_fun.py b/tests/float/cmath_fun.py index 3ebcf59186..ae5921c304 100644 --- a/tests/float/cmath_fun.py +++ b/tests/float/cmath_fun.py @@ -4,8 +4,7 @@ try: from cmath import * except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit # make sure these constants exist in cmath print("%.5g" % e) diff --git a/tests/float/cmath_fun_special.py b/tests/float/cmath_fun_special.py index 422964dd75..471fda8c0d 100644 --- a/tests/float/cmath_fun_special.py +++ b/tests/float/cmath_fun_special.py @@ -5,8 +5,7 @@ try: log10 except (ImportError, NameError): print("SKIP") - import sys - sys.exit() + raise SystemExit test_values_non_zero = [] base_values = (0.0, 0.5, 1.2345, 10.) diff --git a/tests/float/float_array.py b/tests/float/float_array.py index 8bc9634449..8c8edcff7c 100644 --- a/tests/float/float_array.py +++ b/tests/float/float_array.py @@ -1,9 +1,8 @@ try: from array import array except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit def test(a): print(a) diff --git a/tests/float/float_struct.py b/tests/float/float_struct.py index a36ccce38b..c4c186b89e 100644 --- a/tests/float/float_struct.py +++ b/tests/float/float_struct.py @@ -5,9 +5,8 @@ try: except: import struct except ImportError: - import sys print("SKIP") - sys.exit() + raise SystemExit i = 1. + 1/2 # TODO: it looks like '=' format modifier is not yet supported diff --git a/tests/float/math_fun.py b/tests/float/math_fun.py index d9f179587d..80d20bd8a5 100644 --- a/tests/float/math_fun.py +++ b/tests/float/math_fun.py @@ -4,8 +4,7 @@ try: from math import * except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit test_values = [-100., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 100.] test_values_small = [-10., -1.23456, -1, -0.5, 0.0, 0.5, 1.23456, 10.] # so we don't overflow 32-bit precision diff --git a/tests/float/math_fun_bool.py b/tests/float/math_fun_bool.py index 57232857ab..30ab14a522 100644 --- a/tests/float/math_fun_bool.py +++ b/tests/float/math_fun_bool.py @@ -4,8 +4,7 @@ try: from math import isfinite, isnan, isinf except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit test_values = [1, 0, -1, 1.0, 0.0, -1.0, float('NaN'), float('Inf'), -float('NaN'), -float('Inf')] diff --git a/tests/float/math_fun_int.py b/tests/float/math_fun_int.py index ee54f0995a..5cadbb1e52 100644 --- a/tests/float/math_fun_int.py +++ b/tests/float/math_fun_int.py @@ -4,8 +4,7 @@ try: import math except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit for fun in (math.ceil, math.floor, math.trunc): for x in (-1.6, -0.2, 0, 0.6, 1.4, float('inf'), float('nan')): diff --git a/tests/float/math_fun_intbig.py b/tests/float/math_fun_intbig.py index 962c10daa8..697ca7a6db 100644 --- a/tests/float/math_fun_intbig.py +++ b/tests/float/math_fun_intbig.py @@ -4,8 +4,7 @@ try: import math except ImportError: print("SKIP") - import sys - sys.exit() + raise SystemExit for fun in (math.ceil, math.floor, math.trunc): for x in (-1e25, 1e25): diff --git a/tests/float/math_fun_special.py b/tests/float/math_fun_special.py index 32249b4234..c3665a7cd9 100644 --- a/tests/float/math_fun_special.py +++ b/tests/float/math_fun_special.py @@ -5,8 +5,7 @@ try: erf except (ImportError, NameError): print("SKIP") - import sys - sys.exit() + raise SystemExit test_values = [-8., -2.5, -1, -0.5, 0.0, 0.5, 2.5, 8.,] pos_test_values = [0.001, 0.1, 0.5, 1.0, 1.5, 10.,]