'Run \'script\' lines with pdb and the pdb \'commands\'.'

def run_pdb(self, script, commands):

    filename = 'main.py'
    with open(filename, 'w') as f:
        f.write(textwrap.dedent(script))
    self.addCleanup(test_support.unlink, filename)
    cmd = [sys.executable, '-m', 'pdb', filename]
    stdout = stderr = None
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.STDOUT)
    (stdout, stderr) = proc.communicate(commands)
    proc.stdout.close()
    proc.stdin.close()
    return (stdout, stderr)
