diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2020-05-17 02:53:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-17 02:53:57 (GMT) |
commit | 6341fc7257d89d798675ad6e425f7eb0b6f2b4bb (patch) | |
tree | 70dd21c1b203eeaaa7160b7eec12ca12631e6a91 /Lib | |
parent | af8e5f84d909487a66558d086cb1754f49221236 (diff) | |
download | cpython-6341fc7257d89d798675ad6e425f7eb0b6f2b4bb.zip cpython-6341fc7257d89d798675ad6e425f7eb0b6f2b4bb.tar.gz cpython-6341fc7257d89d798675ad6e425f7eb0b6f2b4bb.tar.bz2 |
bpo-38870: Use subTest in test_unparse for better error reporting (GH-20141)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_unparse.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index d543ca2..67dcb1d 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -120,13 +120,15 @@ class ASTTestCase(unittest.TestCase): self.assertEqual(ast.dump(ast1), ast.dump(ast2)) def check_ast_roundtrip(self, code1, **kwargs): - ast1 = ast.parse(code1, **kwargs) - code2 = ast.unparse(ast1) - ast2 = ast.parse(code2, **kwargs) - self.assertASTEqual(ast1, ast2) + with self.subTest(code1=code1, ast_parse_kwargs=kwargs): + ast1 = ast.parse(code1, **kwargs) + code2 = ast.unparse(ast1) + ast2 = ast.parse(code2, **kwargs) + self.assertASTEqual(ast1, ast2) def check_invalid(self, node, raises=ValueError): - self.assertRaises(raises, ast.unparse, node) + with self.subTest(node=node): + self.assertRaises(raises, ast.unparse, node) def get_source(self, code1, code2=None): code2 = code2 or code1 @@ -135,11 +137,13 @@ class ASTTestCase(unittest.TestCase): def check_src_roundtrip(self, code1, code2=None): code1, code2 = self.get_source(code1, code2) - self.assertEqual(code2, code1) + with self.subTest(code1=code1, code2=code2): + self.assertEqual(code2, code1) def check_src_dont_roundtrip(self, code1, code2=None): code1, code2 = self.get_source(code1, code2) - self.assertNotEqual(code2, code1) + with self.subTest(code1=code1, code2=code2): + self.assertNotEqual(code2, code1) class UnparseTestCase(ASTTestCase): # Tests for specific bugs found in earlier versions of unparse |