@@ -17,7 +17,7 @@ class Foobar:
1717
1818
1919@pytest .mark .parametrize (
20- 'deps,code,locals ,expected' ,
20+ 'deps,code,globals ,expected' ,
2121 [
2222 pytest .param (
2323 [],
@@ -26,6 +26,13 @@ class Foobar:
2626 snapshot ({'status' : 'success' , 'output' : [], 'return_value' : 2 }),
2727 id = 'return-value-success' ,
2828 ),
29+ pytest .param (
30+ [],
31+ '"foobar"' ,
32+ {},
33+ snapshot ({'status' : 'success' , 'output' : [], 'return_value' : 'foobar' }),
34+ id = 'return-string' ,
35+ ),
2936 pytest .param (
3037 [],
3138 'print(123)' ,
@@ -38,28 +45,35 @@ class Foobar:
3845 'a' ,
3946 {'a' : [1 , 2 , 3 ]},
4047 snapshot ({'status' : 'success' , 'output' : [], 'return_value' : [1 , 2 , 3 ]}),
41- id = 'access-local -variables' ,
48+ id = 'access-global -variables' ,
4249 ),
4350 pytest .param (
4451 [],
4552 'a + b' ,
4653 {'a' : 4 , 'b' : 5 },
4754 snapshot ({'status' : 'success' , 'output' : [], 'return_value' : 9 }),
48- id = 'multiple-locals ' ,
55+ id = 'multiple-globals ' ,
4956 ),
5057 pytest .param (
5158 [],
5259 'print(f)' ,
5360 {'f' : Foobar (1 , '2' , b'3' )},
5461 snapshot ({'status' : 'success' , 'output' : ["{'a': 1, 'b': '2', 'c': '3'}" ], 'return_value' : None }),
55- id = 'print-complex-local' ,
62+ id = 'print-complex-global' ,
63+ ),
64+ pytest .param (
65+ [],
66+ 'f' ,
67+ {'f' : Foobar (1 , '2' , b'3' )},
68+ snapshot ({'status' : 'success' , 'output' : [], 'return_value' : {'a' : 1 , 'b' : '2' , 'c' : '3' }}),
69+ id = 'return-complex-global' ,
5670 ),
5771 pytest .param (
5872 [],
5973 'f' ,
6074 {'f' : Foobar (1 , '2' , b'3' )},
6175 snapshot ({'status' : 'success' , 'output' : [], 'return_value' : {'a' : 1 , 'b' : '2' , 'c' : '3' }}),
62- id = 'return-complex-local ' ,
76+ id = 'return-complex-global ' ,
6377 ),
6478 pytest .param (
6579 [],
@@ -134,9 +148,9 @@ def baz():
134148 ),
135149 ],
136150)
137- async def test_sandbox (deps : list [str ], code : str , locals : dict [str , Any ], expected : Any ):
151+ async def test_sandbox (deps : list [str ], code : str , globals : dict [str , Any ], expected : Any ):
138152 async with code_sandbox (dependencies = deps ) as sandbox :
139- result = await sandbox .eval (code , locals )
153+ result = await sandbox .eval (code , globals )
140154 assert result == expected
141155
142156
0 commit comments