diff options
author | Kodi Arfer <Kodiologist@users.noreply.github.com> | 2021-03-18 17:36:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-18 17:36:06 (GMT) |
commit | 08ff4369afca84587b1c82034af4e9f64caddbf2 (patch) | |
tree | dc3651017ab316e451c13f84a6686d20faf7441e /Lib/test/test_unparse.py | |
parent | eec8e61992fb654d4cf58de4d727c18622b8303e (diff) | |
download | cpython-08ff4369afca84587b1c82034af4e9f64caddbf2.zip cpython-08ff4369afca84587b1c82034af4e9f64caddbf2.tar.gz cpython-08ff4369afca84587b1c82034af4e9f64caddbf2.tar.bz2 |
bpo-43521: Allow ast.unparse with empty sets and NaN (GH-24897)
Automerge-Triggered-By: GH:pablogsal
Diffstat (limited to 'Lib/test/test_unparse.py')
-rw-r--r-- | Lib/test/test_unparse.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index c7c8613..ce03272 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -199,6 +199,12 @@ class UnparseTestCase(ASTTestCase): self.check_ast_roundtrip("1e1000j") self.check_ast_roundtrip("-1e1000j") + def test_nan(self): + self.assertASTEqual( + ast.parse(ast.unparse(ast.Constant(value=float('nan')))), + ast.parse('1e1000 - 1e1000') + ) + def test_min_int(self): self.check_ast_roundtrip(str(-(2 ** 31))) self.check_ast_roundtrip(str(-(2 ** 63))) @@ -252,6 +258,12 @@ class UnparseTestCase(ASTTestCase): def test_set_literal(self): self.check_ast_roundtrip("{'a', 'b', 'c'}") + def test_empty_set(self): + self.assertASTEqual( + ast.parse(ast.unparse(ast.Set(elts=[]))), + ast.parse('{*()}') + ) + def test_set_comprehension(self): self.check_ast_roundtrip("{x for x in range(5)}") @@ -326,9 +338,6 @@ class UnparseTestCase(ASTTestCase): def test_invalid_fstring_backslash(self): self.check_invalid(ast.FormattedValue(value=ast.Constant(value="\\\\"))) - def test_invalid_set(self): - self.check_invalid(ast.Set(elts=[])) - def test_invalid_yield_from(self): self.check_invalid(ast.YieldFrom(value=None)) |