2
2
import unittest
3
3
from test .support import python_is_optimized
4
4
5
- from .util import run_gdb , setup_module , DebuggerTests
5
+ from .util import run_gdb , setup_module , DebuggerTests , SAMPLE_SCRIPT
6
6
7
7
8
8
def setUpModule ():
@@ -32,7 +32,7 @@ def assertListing(self, expected, actual):
32
32
33
33
def test_basic_command (self ):
34
34
'Verify that the "py-list" command works'
35
- bt = self .get_stack_trace (script = self . get_sample_script () ,
35
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
36
36
cmds_after_breakpoint = ['py-list' ])
37
37
38
38
self .assertListing (' 5 \n '
@@ -47,7 +47,7 @@ def test_basic_command(self):
47
47
48
48
def test_one_abs_arg (self ):
49
49
'Verify the "py-list" command with one absolute argument'
50
- bt = self .get_stack_trace (script = self . get_sample_script () ,
50
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
51
51
cmds_after_breakpoint = ['py-list 9' ])
52
52
53
53
self .assertListing (' 9 def baz(*args):\n '
@@ -58,7 +58,7 @@ def test_one_abs_arg(self):
58
58
59
59
def test_two_abs_args (self ):
60
60
'Verify the "py-list" command with two absolute arguments'
61
- bt = self .get_stack_trace (script = self . get_sample_script () ,
61
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
62
62
cmds_after_breakpoint = ['py-list 1,3' ])
63
63
64
64
self .assertListing (' 1 # Sample script for use by test_gdb\n '
@@ -101,15 +101,15 @@ def test_pyup_command(self):
101
101
@unittest .skipUnless (HAS_PYUP_PYDOWN , "test requires py-up/py-down commands" )
102
102
def test_down_at_bottom (self ):
103
103
'Verify handling of "py-down" at the bottom of the stack'
104
- bt = self .get_stack_trace (script = self . get_sample_script () ,
104
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
105
105
cmds_after_breakpoint = ['py-down' ])
106
106
self .assertEndsWith (bt ,
107
107
'Unable to find a newer python frame\n ' )
108
108
109
109
@unittest .skipUnless (HAS_PYUP_PYDOWN , "test requires py-up/py-down commands" )
110
110
def test_up_at_top (self ):
111
111
'Verify handling of "py-up" at the top of the stack'
112
- bt = self .get_stack_trace (script = self . get_sample_script () ,
112
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
113
113
cmds_after_breakpoint = ['py-up' ] * 5 )
114
114
self .assertEndsWith (bt ,
115
115
'Unable to find an older python frame\n ' )
@@ -150,15 +150,15 @@ def test_print_after_up(self):
150
150
@unittest .skipIf (python_is_optimized (),
151
151
"Python was compiled with optimizations" )
152
152
def test_printing_global (self ):
153
- bt = self .get_stack_trace (script = self . get_sample_script () ,
153
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
154
154
cmds_after_breakpoint = ['py-up' , 'py-print __name__' ])
155
155
self .assertMultilineMatches (bt ,
156
156
r".*\nglobal '__name__' = '__main__'\n.*" )
157
157
158
158
@unittest .skipIf (python_is_optimized (),
159
159
"Python was compiled with optimizations" )
160
160
def test_printing_builtin (self ):
161
- bt = self .get_stack_trace (script = self . get_sample_script () ,
161
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
162
162
cmds_after_breakpoint = ['py-up' , 'py-print len' ])
163
163
self .assertMultilineMatches (bt ,
164
164
r".*\nbuiltin 'len' = <built-in method len of module object at remote 0x-?[0-9a-f]+>\n.*" )
@@ -167,7 +167,7 @@ class PyLocalsTests(DebuggerTests):
167
167
@unittest .skipIf (python_is_optimized (),
168
168
"Python was compiled with optimizations" )
169
169
def test_basic_command (self ):
170
- bt = self .get_stack_trace (script = self . get_sample_script () ,
170
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
171
171
cmds_after_breakpoint = ['py-up' , 'py-locals' ])
172
172
self .assertMultilineMatches (bt ,
173
173
r".*\nargs = \(1, 2, 3\)\n.*" )
@@ -176,7 +176,7 @@ def test_basic_command(self):
176
176
@unittest .skipIf (python_is_optimized (),
177
177
"Python was compiled with optimizations" )
178
178
def test_locals_after_up (self ):
179
- bt = self .get_stack_trace (script = self . get_sample_script () ,
179
+ bt = self .get_stack_trace (script = SAMPLE_SCRIPT ,
180
180
cmds_after_breakpoint = ['py-up' , 'py-up' , 'py-locals' ])
181
181
self .assertMultilineMatches (bt ,
182
182
r'''^.*
0 commit comments