Run the Python REPL with the given arguments. kw is extra keyword args to pass to subprocess.Popen. Returns a Popen object.
(self, *args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw)
| 6577 | class TestRepl(unittest.TestCase): |
| 6578 | |
| 6579 | def spawn_repl(self, *args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw): |
| 6580 | """Run the Python REPL with the given arguments. |
| 6581 | |
| 6582 | kw is extra keyword args to pass to subprocess.Popen. Returns a Popen |
| 6583 | object. |
| 6584 | """ |
| 6585 | |
| 6586 | # TODO(picnixz): refactor this as it's used by test_repl.py |
| 6587 | |
| 6588 | # To run the REPL without using a terminal, spawn python with the command |
| 6589 | # line option '-i' and the process name set to '<stdin>'. |
| 6590 | # The directory of argv[0] must match the directory of the Python |
| 6591 | # executable for the Popen() call to python to succeed as the directory |
| 6592 | # path may be used by PyConfig_Get("module_search_paths") to build the |
| 6593 | # default module search path. |
| 6594 | stdin_fname = os.path.join(os.path.dirname(sys.executable), "<stdin>") |
| 6595 | cmd_line = [stdin_fname, '-E', '-i'] |
| 6596 | cmd_line.extend(args) |
| 6597 | |
| 6598 | # Set TERM=vt100, for the rationale see the comments in spawn_python() of |
| 6599 | # test.support.script_helper. |
| 6600 | env = kw.setdefault('env', dict(os.environ)) |
| 6601 | env['TERM'] = 'vt100' |
| 6602 | return subprocess.Popen(cmd_line, |
| 6603 | executable=sys.executable, |
| 6604 | text=True, |
| 6605 | stdin=subprocess.PIPE, |
| 6606 | stdout=stdout, stderr=stderr, |
| 6607 | **kw) |
| 6608 | |
| 6609 | def run_on_interactive_mode(self, source): |
| 6610 | """Spawn a new Python interpreter, pass the given |
no test coverage detected