mirror of
https://github.com/python/cpython.git
synced 2025-07-29 06:05:00 +00:00
Make AST nodes pickleable.
This commit is contained in:
parent
1721e75749
commit
e34c21c2a0
3 changed files with 68 additions and 4 deletions
|
@ -166,6 +166,20 @@ class AST_Tests(unittest.TestCase):
|
|||
# this used to fail because Sub._fields was None
|
||||
x = _ast.Sub()
|
||||
|
||||
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.assertEquals(to_tuple(ast2), to_tuple(ast))
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(AST_Tests)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue