Commit a62e4c60 authored by Shane Hathaway's avatar Shane Hathaway

Added a test that ensures Jeremy's compiler estimates the stack size of a

function at least as conservatively as the standard compiler does.  Note
that this test currently fails for list comprehensions.
parent 7b380f43
......@@ -8,7 +8,7 @@ if __name__=='__main__':
import unittest
from RestrictedPython import compile_restricted, PrintCollector
from RestrictedPython.Eval import RestrictionCapableEval
from RestrictedPython.tests import security_in_syntax
from RestrictedPython.tests import restricted_module, security_in_syntax
from types import FunctionType
if __name__=='__main__':
......@@ -268,6 +268,16 @@ class RestrictionTests(unittest.TestCase):
res = expr(m=v)
assert res == expect
def checkStackSize(self):
for k, rfunc in rmodule.items():
if not k.startswith('_') and hasattr(rfunc, 'func_code'):
rss = rfunc.func_code.co_stacksize
ss = getattr(restricted_module, k).func_code.co_stacksize
self.failUnless(
rss >= ss, 'The stack size estimate for %s() '
'should have been at least %d, but was only %d'
% (k, ss, rss))
def test_suite():
return unittest.makeSuite(RestrictionTests, 'check')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment