Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_help(command, expected_regex):
instance = PdbTest()
instance.stdout = StringIO()
# Redirect sys.stdout because Python 2 pdb.py has `print >>self.stdout` for
# some functions and plain ol' `print` for others.
oldstdout = sys.stdout
sys.stdout = instance.stdout
try:
instance.do_help(command)
finally:
sys.stdout = oldstdout
output = instance.stdout.getvalue()
assert re.search(expected_regex, output)