From a8711824e7e967bb4a547cf5cbc88a6c1ed46412 Mon Sep 17 00:00:00 2001 From: Samar Date: Wed, 4 Nov 2026 22:09:29 -0600 Subject: [PATCH] gh-131178: Add tests for symtable command-line interface --- Lib/test/test_symtable.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index da00b0bfa74b125..0ac7d6a6803a4fa 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()