From d007cb890394d9d26c6fafb133532a5175d91eb2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 21 Aug 2015 11:56:14 +0100 Subject: tests: Add more tests to improve coverage, mostly testing exceptions. --- tests/float/string_format.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/float/string_format.py') diff --git a/tests/float/string_format.py b/tests/float/string_format.py index 9ffbec4ff..b605f2097 100644 --- a/tests/float/string_format.py +++ b/tests/float/string_format.py @@ -6,12 +6,14 @@ full_tests = False def test(fmt, *args): print('{:8s}'.format(fmt) + '>' + fmt.format(*args) + '<') +test("{:10.4}", 123.456) test("{:10.4e}", 123.456) test("{:10.4e}", -123.456) test("{:10.4f}", 123.456) test("{:10.4f}", -123.456) test("{:10.4g}", 123.456) test("{:10.4g}", -123.456) +test("{:10.4n}", 123.456) test("{:e}", 100) test("{:f}", 200) test("{:g}", 300) @@ -128,3 +130,10 @@ else: # We don't currently test a type of '' with floats (see the detailed comment # in objstr.c) + +# tests for errors in format string + +try: + '{:10.1b}'.format(0.0) +except ValueError: + print('ValueError') -- cgit v1.2.3