diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index da00b0bfa74b12..0ac7d6a6803a4f 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -9,6 +9,7 @@ from test import support from test.support import os_helper +from test.support.script_helper import assert_python_ok TEST_CODE = """ @@ -910,5 +911,22 @@ def test_stdin(self): self.assertIn("symbol table for module from file '':", lines) +class CommandLineSubprocessTest(unittest.TestCase): + + @support.requires_subprocess() + def test_file(self): + filename = os_helper.TESTFN + with open(filename, 'w') as f: + f.write("x = 1\n") + self.addCleanup(os_helper.unlink, filename) + + rc, stdout, stderr = assert_python_ok('-m', 'symtable', filename) + self.assertIn( + f"symbol table for module from file {filename!r}:".encode(), stdout + ) + self.assertIn(b"local symbol 'x': def_local", stdout) + self.assertEqual(stderr, b'') + + if __name__ == '__main__': unittest.main()