Run 'script' lines with pdb and the pdb 'commands'.
(self, script, commands,
expected_returncode=0,
extra_env=None,
script_args=None,
pdbrc=None,
remove_home=False)
| 3557 | return stdout, stderr |
| 3558 | |
| 3559 | def run_pdb_script(self, script, commands, |
| 3560 | expected_returncode=0, |
| 3561 | extra_env=None, |
| 3562 | script_args=None, |
| 3563 | pdbrc=None, |
| 3564 | remove_home=False): |
| 3565 | """Run 'script' lines with pdb and the pdb 'commands'.""" |
| 3566 | filename = 'main.py' |
| 3567 | with open(filename, 'w') as f: |
| 3568 | f.write(textwrap.dedent(script)) |
| 3569 | |
| 3570 | if pdbrc is not None: |
| 3571 | with open('.pdbrc', 'w') as f: |
| 3572 | f.write(textwrap.dedent(pdbrc)) |
| 3573 | self.addCleanup(os_helper.unlink, '.pdbrc') |
| 3574 | self.addCleanup(os_helper.unlink, filename) |
| 3575 | |
| 3576 | with os_helper.EnvironmentVarGuard() as env: |
| 3577 | if remove_home: |
| 3578 | env.unset('HOME') |
| 3579 | if script_args is None: |
| 3580 | script_args = [] |
| 3581 | stdout, stderr = self._run_pdb([filename] + script_args, commands, expected_returncode, extra_env) |
| 3582 | return stdout, stderr |
| 3583 | |
| 3584 | def run_pdb_module(self, script, commands): |
| 3585 | """Runs the script code as part of a module""" |
no test coverage detected