<s> from sandbox import Sandbox , SandboxError , HAVE_CSANDBOX , HAVE_PYPY <EOL> from sandbox . test import SkipTest , createSandbox , createSandboxConfig , unindent <EOL> from sys import version_info <EOL> def test_call_exec_builtins ( ) : <EOL> code = unindent ( '''<STR_LIT>''' ) <EOL> config = createSandboxConfig ( ) <EOL> if HAVE_PYPY : <EOL> config . _builtins_whitelist . add ( '<STR_LIT>' ) <EOL> Sandbox ( config ) . execute ( code ) <EOL> def test_exec_builtins ( ) : <EOL> config = createSandboxConfig ( ) <EOL> Sandbox ( config ) . execute ( """<STR_LIT>""" . strip ( ) ) <EOL> def test_builtins_setitem ( ) : <EOL> code = unindent ( '''<STR_LIT>''' ) <EOL> unsafe_code = code + unindent ( '''<STR_LIT>''' ) <EOL> createSandbox ( ) . execute ( unsafe_code ) <EOL> safe_code = code + unindent ( '''<STR_LIT>''' ) <EOL> execute_code ( safe_code ) <EOL> def test_builtins_init ( ) : <EOL> import warnings <EOL> code = unindent ( '''<STR_LIT>''' ) <EOL> unsafe_code = code + unindent ( '''<STR_LIT>''' ) <EOL> try : <EOL> createSandbox ( ) . execute ( unsafe_code ) <EOL> except SandboxError , err : <EOL> assert str ( err ) == "<STR_LIT>" , str ( err ) <EOL> else : <EOL> assert False <EOL> def test_modify_builtins_dict ( ) : <EOL> code = unindent ( '''<STR_LIT>''' ) <EOL> unsafe_code = code + unindent ( '''<STR_LIT>''' ) <EOL> try : <EOL> createSandbox ( ) . execute ( unsafe_code ) <EOL> except SandboxError , err : <EOL> assert str ( err ) == "<STR_LIT>" <EOL> def test_del_builtin ( ) : <EOL> code = unindent ( '''<STR_LIT>''' ) <EOL> unsafe_code = code + unindent ( '''<STR_LIT>''' ) <EOL> config = createSandboxConfig ( ) <EOL> config . allowModule ( '<STR_LIT>' ) <EOL> Sandbox ( config ) . execute ( unsafe_code ) </s>
