@@ -33,10 +33,10 @@ def _captured_script(script):
3333 return wrapped, open(r, encoding="utf-8")
3434
3535
36- def _run_output(interp, request, shared=None ):
36+ def _run_output(interp, request):
3737 script, rpipe = _captured_script(request)
3838 with rpipe:
39- interpreters.run_string(interp, script, shared )
39+ interpreters.run_string(interp, script)
4040 return rpipe.read()
4141
4242
@@ -630,10 +630,10 @@ def test_shareable_types(self):
630630 ]
631631 for obj in objects:
632632 with self.subTest(obj):
633+ interpreters.set___main___attrs(interp, dict(obj=obj))
633634 interpreters.run_string(
634635 interp,
635636 f'assert(obj == {obj!r})',
636- shared=dict(obj=obj),
637637 )
638638
639639 def test_os_exec(self):
@@ -721,7 +721,8 @@ def test_with_shared(self):
721721 with open({w}, 'wb') as chan:
722722 pickle.dump(ns, chan)
723723 """)
724- interpreters.run_string(self.id, script, shared)
724+ interpreters.set___main___attrs(self.id, shared)
725+ interpreters.run_string(self.id, script)
725726 with open(r, 'rb') as chan:
726727 ns = pickle.load(chan)
727728
@@ -742,7 +743,8 @@ def test_shared_overwrites(self):
742743 ns2 = dict(vars())
743744 del ns2['__builtins__']
744745 """)
745- interpreters.run_string(self.id, script, shared)
746+ interpreters.set___main___attrs(self.id, shared)
747+ interpreters.run_string(self.id, script)
746748
747749 r, w = os.pipe()
748750 script = dedent(f"""
@@ -773,7 +775,8 @@ def test_shared_overwrites_default_vars(self):
773775 with open({w}, 'wb') as chan:
774776 pickle.dump(ns, chan)
775777 """)
776- interpreters.run_string(self.id, script, shared)
778+ interpreters.set___main___attrs(self.id, shared)
779+ interpreters.run_string(self.id, script)
777780 with open(r, 'rb') as chan:
778781 ns = pickle.load(chan)
779782
@@ -1036,7 +1039,8 @@ def script():
10361039 with open(w, 'w', encoding="utf-8") as spipe:
10371040 with contextlib.redirect_stdout(spipe):
10381041 print('it worked!', end='')
1039- interpreters.run_func(self.id, script, shared=dict(w=w))
1042+ interpreters.set___main___attrs(self.id, dict(w=w))
1043+ interpreters.run_func(self.id, script)
10401044
10411045 with open(r, encoding="utf-8") as outfile:
10421046 out = outfile.read()
@@ -1052,7 +1056,8 @@ def script():
10521056 with contextlib.redirect_stdout(spipe):
10531057 print('it worked!', end='')
10541058 def f():
1055- interpreters.run_func(self.id, script, shared=dict(w=w))
1059+ interpreters.set___main___attrs(self.id, dict(w=w))
1060+ interpreters.run_func(self.id, script)
10561061 t = threading.Thread(target=f)
10571062 t.start()
10581063 t.join()
@@ -1072,7 +1077,8 @@ def script():
10721077 with contextlib.redirect_stdout(spipe):
10731078 print('it worked!', end='')
10741079 code = script.__code__
1075- interpreters.run_func(self.id, code, shared=dict(w=w))
1080+ interpreters.set___main___attrs(self.id, dict(w=w))
1081+ interpreters.run_func(self.id, code)
10761082
10771083 with open(r, encoding="utf-8") as outfile:
10781084 out = outfile.read()
0 commit comments