22import unittest
33from test .support import python_is_optimized
44
5- from .util import run_gdb , setup_module , DebuggerTests
5+ from .util import run_gdb , setup_module , DebuggerTests , SAMPLE_SCRIPT
66
77
88def setUpModule ():
@@ -32,7 +32,7 @@ def assertListing(self, expected, actual):
3232
3333 def test_basic_command (self ):
3434 '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 ,
3636 cmds_after_breakpoint = ['py-list' ])
3737
3838 self .assertListing (' 5 \n '
@@ -47,7 +47,7 @@ def test_basic_command(self):
4747
4848 def test_one_abs_arg (self ):
4949 '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 ,
5151 cmds_after_breakpoint = ['py-list 9' ])
5252
5353 self .assertListing (' 9 def baz(*args):\n '
@@ -58,7 +58,7 @@ def test_one_abs_arg(self):
5858
5959 def test_two_abs_args (self ):
6060 '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 ,
6262 cmds_after_breakpoint = ['py-list 1,3' ])
6363
6464 self .assertListing (' 1 # Sample script for use by test_gdb\n '
@@ -101,15 +101,15 @@ def test_pyup_command(self):
101101 @unittest .skipUnless (HAS_PYUP_PYDOWN , "test requires py-up/py-down commands" )
102102 def test_down_at_bottom (self ):
103103 '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 ,
105105 cmds_after_breakpoint = ['py-down' ])
106106 self .assertEndsWith (bt ,
107107 'Unable to find a newer python frame\n ' )
108108
109109 @unittest .skipUnless (HAS_PYUP_PYDOWN , "test requires py-up/py-down commands" )
110110 def test_up_at_top (self ):
111111 '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 ,
113113 cmds_after_breakpoint = ['py-up' ] * 5 )
114114 self .assertEndsWith (bt ,
115115 'Unable to find an older python frame\n ' )
@@ -150,15 +150,15 @@ def test_print_after_up(self):
150150 @unittest .skipIf (python_is_optimized (),
151151 "Python was compiled with optimizations" )
152152 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 ,
154154 cmds_after_breakpoint = ['py-up' , 'py-print __name__' ])
155155 self .assertMultilineMatches (bt ,
156156 r".*\nglobal '__name__' = '__main__'\n.*" )
157157
158158 @unittest .skipIf (python_is_optimized (),
159159 "Python was compiled with optimizations" )
160160 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 ,
162162 cmds_after_breakpoint = ['py-up' , 'py-print len' ])
163163 self .assertMultilineMatches (bt ,
164164 r".*\nbuiltin 'len' = <built-in method len of module object at remote 0x-?[0-9a-f]+>\n.*" )
@@ -167,7 +167,7 @@ class PyLocalsTests(DebuggerTests):
167167 @unittest .skipIf (python_is_optimized (),
168168 "Python was compiled with optimizations" )
169169 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 ,
171171 cmds_after_breakpoint = ['py-up' , 'py-locals' ])
172172 self .assertMultilineMatches (bt ,
173173 r".*\nargs = \(1, 2, 3\)\n.*" )
@@ -176,7 +176,7 @@ def test_basic_command(self):
176176 @unittest .skipIf (python_is_optimized (),
177177 "Python was compiled with optimizations" )
178178 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 ,
180180 cmds_after_breakpoint = ['py-up' , 'py-up' , 'py-locals' ])
181181 self .assertMultilineMatches (bt ,
182182 r'''^.*
0 commit comments