summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-03-30 20:20:39 (GMT)
committerGeorg Brandl <georg@python.org>2008-03-30 20:20:39 (GMT)
commite34c21c2a006e4ac950a519e1e662750f3e09e79 (patch)
treeacff8462559760d3928aeb12edc14d6437f63ff8 /Lib/test
parent1721e757499db93373cba263b0553a64d4c545a3 (diff)
downloadcpython-e34c21c2a006e4ac950a519e1e662750f3e09e79.zip
cpython-e34c21c2a006e4ac950a519e1e662750f3e09e79.tar.gz
cpython-e34c21c2a006e4ac950a519e1e662750f3e09e79.tar.bz2
Make AST nodes pickleable.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_ast.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index e068b0a..9d2bd66 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -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)