summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_capi.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2012-01-17 23:22:06 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2012-01-17 23:22:06 (GMT)
commit7422b22e5e2b5462908b4f5f45574ef2de7961c6 (patch)
tree7e97fd259a3898ba549f15fc360850d8e878de4a /Lib/test/test_capi.py
parent5e8260b09c2aa3faa7ec4722b44e452072301b20 (diff)
parent2f828f2c8859b331bf9519bdc660eb8a2288779a (diff)
downloadcpython-7422b22e5e2b5462908b4f5f45574ef2de7961c6.zip
cpython-7422b22e5e2b5462908b4f5f45574ef2de7961c6.tar.gz
cpython-7422b22e5e2b5462908b4f5f45574ef2de7961c6.tar.bz2
Test running of code in a sub-interpreter
(prelude to issue #6531).
Diffstat (limited to 'Lib/test/test_capi.py')
-rw-r--r--Lib/test/test_capi.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index c649d3e..2f94f90 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -3,6 +3,7 @@
from __future__ import with_statement
import os
+import pickle
import random
import subprocess
import sys
@@ -137,6 +138,22 @@ class TestPendingCalls(unittest.TestCase):
self.pendingcalls_submit(l, n)
self.pendingcalls_wait(l, n)
+ def test_subinterps(self):
+ # XXX this test leaks in refleak runs
+ import builtins
+ r, w = os.pipe()
+ code = """if 1:
+ import sys, builtins, pickle
+ with open({:d}, "wb") as f:
+ pickle.dump(id(sys.modules), f)
+ pickle.dump(id(builtins), f)
+ """.format(w)
+ with open(r, "rb") as f:
+ ret = _testcapi.run_in_subinterp(code)
+ self.assertEqual(ret, 0)
+ self.assertNotEqual(pickle.load(f), id(sys.modules))
+ self.assertNotEqual(pickle.load(f), id(builtins))
+
# Bug #6012
class Test6012(unittest.TestCase):
def test(self):