Skip to content

Commit 28c07d6

Browse files
Simplify test
1 parent 39f9bc3 commit 28c07d6

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
import gc
77
import os
88
import types
9-
import tempfile
10-
import subprocess
119

1210
import _opcode
1311

1412
from test.support import (script_helper, requires_specialization,
1513
import_helper, Py_GIL_DISABLED, requires_jit_enabled,
16-
reset_code, requires_subprocess)
14+
reset_code)
1715

1816
_testinternalcapi = import_helper.import_module("_testinternalcapi")
1917

@@ -2662,9 +2660,8 @@ def f():
26622660

26632661
f()
26642662

2665-
@requires_subprocess()
26662663
def test_interpreter_finalization_with_generator_alive(self):
2667-
code = textwrap.dedent("""
2664+
script_helper.assert_python_ok("-c", textwrap.dedent("""
26682665
import sys
26692666
def simple_for():
26702667
for x in (1, 2):
@@ -2680,20 +2677,8 @@ def gen():
26802677
simple_for()
26812678
g = gen()
26822679
next(g)
2683-
print("finished", end='')
2684-
""")
2680+
"""))
26852681

2686-
tmp = tempfile.NamedTemporaryFile(delete=False, suffix='.py')
2687-
tmp.write(code.encode('utf-8'))
2688-
tmp.close()
2689-
try:
2690-
p = subprocess.Popen([sys.executable, tmp.name], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
2691-
p.wait()
2692-
out = p.stdout.read()
2693-
finally:
2694-
os.remove(tmp.name)
2695-
p.stdout.close()
2696-
self.assertEqual(b"finished", out)
26972682

26982683
def global_identity(x):
26992684
return x

0 commit comments

Comments
 (0)