Skip to content

Commit ec6ed07

Browse files
johnslavikvstinner
andcommitted
Use big boy guns for the subprocess test
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent e498ab5 commit ec6ed07

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Lib/test/test_lazy_import/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import os
1313

1414
from test import support
15+
from test.support.script_helper import assert_python_ok
1516

1617
try:
1718
import _testcapi
@@ -226,14 +227,8 @@ def test_lazy_import_type_attributes_accessible(self):
226227
lazy import json
227228
print(globals()["json"].resolve)
228229
""")
229-
result = subprocess.run(
230-
[sys.executable, "-c", code],
231-
capture_output=True,
232-
text=True
233-
)
234-
self.assertEqual(result.returncode, 0, f"stdout: {result.stdout}, stderr: {result.stderr}")
235-
self.assertIn("<built-in method resolve of lazy_import object at", result.stdout)
236-
230+
proc = assert_python_ok("-c", code)
231+
self.assertIn(b"<built-in method resolve of lazy_import object at", proc.out)
237232

238233
class SyntaxRestrictionTests(unittest.TestCase):
239234
"""Tests for syntax restrictions on lazy imports."""

0 commit comments

Comments
 (0)