A unit test that demonstrates the problem we're having with some sandboxed code.

This commit is contained in:
Ned Batchelder
2013-02-26 13:19:19 -05:00
parent d9df65eef0
commit 1473fe377a

View File

@@ -1,6 +1,7 @@
"""Test safe_exec.py"""
import os.path
import textwrap
import unittest
from nose.plugins.skip import SkipTest
@@ -42,6 +43,17 @@ class SafeExecTests(object):
)
self.assertEqual(l['a'], 42)
def test_functions_calling_each_other(self):
g, l = {}, {}
self.safe_exec(textwrap.dedent("""\
def f():
return 1723
def g():
return f()
x = g()
"""), g, l)
self.assertEqual(l['x'], 1723)
class TestSafeExec(SafeExecTests, unittest.TestCase):
"""Run SafeExecTests, with the real safe_exec."""