<s> import doctest <EOL> import imp <EOL> import pdb <EOL> import sys <EOL> import unittest <EOL> import subprocess <EOL> import textwrap <EOL> from test import support <EOL> from test . test_doctest import _FakeInput <EOL> class PdbTestInput ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , input ) : <EOL> self . input = input <EOL> def __enter__ ( self ) : <EOL> self . real_stdin = sys . stdin <EOL> sys . stdin = _FakeInput ( self . input ) <EOL> self . orig_trace = sys . gettrace ( ) if hasattr ( sys , '<STR_LIT>' ) else None <EOL> def __exit__ ( self , * exc ) : <EOL> sys . stdin = self . real_stdin <EOL> if self . orig_trace : <EOL> sys . settrace ( self . orig_trace ) <EOL> def test_pdb_displayhook ( ) : <EOL> """<STR_LIT>""" <EOL> def test_pdb_basic_commands ( ) : <EOL> """<STR_LIT>""" <EOL> def test_pdb_breakpoint_commands ( ) : <EOL> """<STR_LIT>""" <EOL> def do_nothing ( ) : <EOL> pass <EOL> def do_something ( ) : <EOL> print ( <NUM_LIT> ) <EOL> def test_list_commands ( ) : <EOL> """<STR_LIT>""" <EOL> def test_post_mortem ( ) : <EOL> """<STR_LIT>""" <EOL> def test_pdb_skip_modules ( ) : <EOL> """<STR_LIT>""" <EOL> mod = imp . new_module ( '<STR_LIT>' ) <EOL> exec ( '<STR_LIT>' , mod . __dict__ ) <EOL> def test_pdb_skip_modules_with_callback ( ) : <EOL> """<STR_LIT>""" <EOL> def test_pdb_continue_in_bottomframe ( ) : <EOL> """<STR_LIT>""" <EOL> def pdb_invoke ( method , arg ) : <EOL> """<STR_LIT>""" <EOL> import pdb <EOL> getattr ( pdb . Pdb ( nosigint = True ) , method ) ( arg ) <EOL> def test_pdb_run_with_incorrect_argument ( ) : <EOL> """<STR_LIT>""" <EOL> def test_pdb_run_with_code_object ( ) : <EOL> """<STR_LIT>""" <EOL> class PdbTestCase ( unittest . TestCase ) : <EOL> def run_pdb ( self , script , commands ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> with open ( filename , '<STR_LIT:w>' ) as f : <EOL> f . write ( textwrap . dedent ( script ) ) <EOL> self . addCleanup ( support . unlink , filename ) <EOL> cmd = [ sys . executable , '<STR_LIT>' , '<STR_LIT>' , filename ] <EOL> stdout = stderr = None <EOL> with subprocess . Popen ( cmd , stdout = subprocess . PIPE , <EOL> stdin = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT , <EOL> ) as proc : <EOL> stdout , stderr = proc . communicate ( str . encode ( commands ) ) <EOL> stdout = stdout and bytes . decode ( stdout ) <EOL> stderr = stderr and bytes . decode ( stderr ) <EOL> return stdout , stderr <EOL> def test_issue7964 ( self ) : <EOL> with open ( support . TESTFN , '<STR_LIT:wb>' ) as f : <EOL> f . write ( b'<STR_LIT>' ) <EOL> cmd = [ sys . executable , '<STR_LIT>' , '<STR_LIT>' , support . TESTFN ] <EOL> proc = subprocess . Popen ( cmd , <EOL> stdout = subprocess . PIPE , <EOL> stdin = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT , <EOL> ) <EOL> self . addCleanup ( proc . stdout . close ) <EOL> stdout , stderr = proc . communicate ( b'<STR_LIT>' ) <EOL> self . assertNotIn ( b'<STR_LIT>' , stdout , <EOL> "<STR_LIT>" ) <EOL> def test_issue13183 ( self ) : <EOL> script = """<STR_LIT>""" <EOL> commands = """<STR_LIT>""" <EOL> bar = """<STR_LIT>""" <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( textwrap . dedent ( bar ) ) <EOL> self . addCleanup ( support . unlink , '<STR_LIT>' ) <EOL> stdout , stderr = self . run_pdb ( script , commands ) <EOL> self . assertTrue ( <EOL> any ( '<STR_LIT>' in l for l in stdout . splitlines ( ) ) , <EOL> '<STR_LIT>' ) <EOL> def test_issue13210 ( self ) : <EOL> support . import_module ( '<STR_LIT>' ) <EOL> with open ( support . TESTFN , '<STR_LIT:wb>' ) as f : <EOL> f . write ( textwrap . dedent ( """<STR_LIT>""" ) . encode ( '<STR_LIT:ascii>' ) ) <EOL> cmd = [ sys . executable , '<STR_LIT>' , support . TESTFN ] <EOL> proc = subprocess . Popen ( cmd , <EOL> stdout = subprocess . PIPE , <EOL> stdin = subprocess . PIPE , <EOL> stderr = subprocess . STDOUT , <EOL> ) <EOL> self . addCleanup ( proc . stdout . close ) <EOL> stdout , stderr = proc . communicate ( b'<STR_LIT>' ) <EOL> self . assertNotIn ( '<STR_LIT>' , stdout . decode ( ) , <EOL> "<STR_LIT>" ) <EOL> def tearDown ( self ) : <EOL> support . unlink ( support . TESTFN ) <EOL> def load_tests ( * args ) : <EOL> from test import test_pdb <EOL> suites = [ unittest . makeSuite ( PdbTestCase ) , doctest . DocTestSuite ( test_pdb ) ] <EOL> return unittest . TestSuite ( suites ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
