44import platform
55from test .unit .cmdhelper import errmsg , msg , reset_output , setup_unit_test_debugger
66
7- from xdis import PYTHON_VERSION_TRIPLE
8-
97from trepan .processor .cmdbreak import parse_break_cmd
108
119# We have to use this subterfuge because "break" is Python reserved word,
@@ -29,48 +27,58 @@ def test_parse_break_cmd():
2927 cmd .errmsg = errmsg
3028 proc = cmd .proc
3129
32- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break" )
33- assert fi .endswith ("test_cmd_break.py" )
34- assert (None , None , True , True ) == (fn , cond , li > 1 , offset > 0 )
30+ expected_code = test_parse_break_cmd .__code__
31+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break" )
3532
33+ assert isinstance (fi , str )
34+ assert isinstance (li , int )
35+ assert isinstance (offset , int )
36+ assert fi .endswith ("test_cmd_break.py" )
37+ assert (expected_code , None , True , True ) == (code , cond , li > 1 , offset > 0 )
3638 assert fi .endswith (__file__ )
3739
38- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break 11" )
39- assert (None , None , 11 , None ) == (fn , cond , li , offset )
40+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break 11" )
41+ assert isinstance (fi , str )
42+ assert (expected_code , None , 11 , None ) == (code , cond , li , offset )
4043
4144 if platform .system () == "Windows" :
4245 brk_cmd = f'b """{ __file__ } """:8'
4346 else :
4447 brk_cmd = f"b { __file__ } :8"
4548
46- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , brk_cmd )
47-
49+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , brk_cmd )
4850 assert (True , 8 ) == (isinstance (fi , str ), li )
4951 # FIXME: This varies. Why?
50- # assert "<module>" == fn
52+ # assert "<module>" == code
5153
5254 def foo ():
5355 return "bar"
5456
55- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break foo()" )
56- assert (foo , True , True ) == (fn , fi .endswith (__file__ ), li > 1 )
57-
58- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break food()" )
59- assert (None , None , None , None ) == (fn , fi , li , cond )
57+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break foo()" )
58+ assert isinstance (fi , str )
59+ assert isinstance (li , int )
60+ assert (foo , True , True ) == (code , fi .endswith (__file__ ), li > 1 )
6061
61- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "b os.path:5 " )
62- assert (os . path , True , 5 ) == (fn , isinstance ( fi , str ), li )
62+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break food() " )
63+ assert (None , None , None , None ) == (code , fi , li , cond )
6364
64- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "b os.path.join() " )
65- assert (os .path . join , True , True ) == (fn , isinstance (fi , str ), li > 1 )
65+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "b os.path:5 " )
66+ assert (os .path , True , 5 ) == (code , isinstance (fi , str ), li )
6667
67- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break if True " )
68- assert (None , True , True ) == (fn , fi . endswith ( __file__ ), li > 1 )
68+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "b os.path.join() " )
69+ assert (os . path . join , True , True ) == (code , isinstance ( fi , str ), li > 1 )
6970
70- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "b foo() if True" )
71- assert (foo , True , True ) == (fn , fi .endswith (__file__ ), li > 1 )
71+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "break if True" )
72+ assert isinstance (fi , str )
73+ assert isinstance (li , int )
74+ assert (expected_code , True , True ) == (code , fi .endswith (__file__ ), li > 1 )
7275
73- fn , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "br os.path:10 if True" )
76+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "b foo() if True" )
77+ assert isinstance (fi , str )
78+ assert isinstance (li , int )
79+ assert (foo , True , True ) == (code , fi .endswith (__file__ ), li > 1 )
80+ assert isinstance (fi , str )
81+ code , fi , li , cond , offset = parse_break_cmd_wrapper (proc , "br os.path:10 if True" )
7482 assert (True , 10 ) == (isinstance (fi , str ), li )
7583
7684 # FIXME:
0 commit comments