summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_ast.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-01-09 19:20:25 (GMT)
committerGitHub <noreply@github.com>2023-01-09 19:20:25 (GMT)
commit2e80c2a976c13dcb69a654b386164dca362295a3 (patch)
treef6643e4bfe22ac196f409090c326b3ab8ffba646 /Lib/test/test_ast.py
parentf08209874e58d0adbb08bd1dba4f58ba63f571c5 (diff)
downloadcpython-2e80c2a976c13dcb69a654b386164dca362295a3.zip
cpython-2e80c2a976c13dcb69a654b386164dca362295a3.tar.gz
cpython-2e80c2a976c13dcb69a654b386164dca362295a3.tar.bz2
gh-100882: Improve `test_pickling` case in `test_ast.py` (#100883)
Diffstat (limited to 'Lib/test/test_ast.py')
-rw-r--r--Lib/test/test_ast.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index ab6a63f..53a6418 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -639,18 +639,11 @@ class AST_Tests(unittest.TestCase):
def test_pickling(self):
import pickle
- mods = [pickle]
- try:
- import cPickle
- mods.append(cPickle)
- except ImportError:
- pass
- protocols = [0, 1, 2]
- for mod in mods:
- for protocol in protocols:
- for ast in (compile(i, "?", "exec", 0x400) for i in exec_tests):
- ast2 = mod.loads(mod.dumps(ast, protocol))
- self.assertEqual(to_tuple(ast2), to_tuple(ast))
+
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
+ for ast in (compile(i, "?", "exec", 0x400) for i in exec_tests):
+ ast2 = pickle.loads(pickle.dumps(ast, protocol))
+ self.assertEqual(to_tuple(ast2), to_tuple(ast))
def test_invalid_sum(self):
pos = dict(lineno=2, col_offset=3)