@@ -221,48 +221,41 @@ def test_getting_backtrace(self):
221221 gdb_output = self .get_stack_trace ('id(42)' )
222222 self .assertTrue (BREAKPOINT_FN in gdb_output )
223223
224- def get_python_repr (self , val ):
225- args = [sys .executable , '-c' , 'print(repr(%a))' % (val ,)]
226- env = os .environ .copy ()
227- env ['PYTHONHASHSEED' ] = PYTHONHASHSEED
228- output = subprocess .check_output (args , env = env , universal_newlines = True )
229- return output .rstrip ()
230-
231224 def assertGdbRepr (self , val , exp_repr = None , cmds_after_breakpoint = None ):
232225 # Ensure that gdb's rendering of the value in a debugged process
233226 # matches repr(value) in this process:
234227 gdb_repr , gdb_output = self .get_gdb_repr ('id(' + ascii (val ) + ')' ,
235228 cmds_after_breakpoint )
236229 if not exp_repr :
237- exp_repr = self . get_python_repr (val )
230+ exp_repr = repr (val )
238231 self .assertEqual (gdb_repr , exp_repr ,
239232 ('%r did not equal expected %r; full output was:\n %s'
240233 % (gdb_repr , exp_repr , gdb_output )))
241234
242235 def test_int (self ):
243236 'Verify the pretty-printing of various int values'
244- self .assertGdbRepr (42 , '42' )
245- self .assertGdbRepr (0 , '0' )
246- self .assertGdbRepr (- 7 , '-7' )
247- self .assertGdbRepr (1000000000000 , '1000000000000' )
248- self .assertGdbRepr (- 1000000000000000 , '-1000000000000000' )
237+ self .assertGdbRepr (42 )
238+ self .assertGdbRepr (0 )
239+ self .assertGdbRepr (- 7 )
240+ self .assertGdbRepr (1000000000000 )
241+ self .assertGdbRepr (- 1000000000000000 )
249242
250243 def test_singletons (self ):
251244 'Verify the pretty-printing of True, False and None'
252- self .assertGdbRepr (True , 'True' )
253- self .assertGdbRepr (False , 'False' )
254- self .assertGdbRepr (None , 'None' )
245+ self .assertGdbRepr (True )
246+ self .assertGdbRepr (False )
247+ self .assertGdbRepr (None )
255248
256249 def test_dicts (self ):
257250 'Verify the pretty-printing of dictionaries'
258- self .assertGdbRepr ({}, '{}' )
259- self .assertGdbRepr ({'foo' : 'bar' })
260- self .assertGdbRepr ({'foo' : 'bar' , 'douglas' : 42 })
251+ self .assertGdbRepr ({})
252+ self .assertGdbRepr ({'foo' : 'bar' }, "{'foo': 'bar'}" )
253+ self .assertGdbRepr ({'foo' : 'bar' , 'douglas' : 42 }, "{'douglas': 42, 'foo': 'bar'}" )
261254
262255 def test_lists (self ):
263256 'Verify the pretty-printing of lists'
264- self .assertGdbRepr ([], '[]' )
265- self .assertGdbRepr (list (range (5 )), '[0, 1, 2, 3, 4]' )
257+ self .assertGdbRepr ([])
258+ self .assertGdbRepr (list (range (5 )))
266259
267260 def test_bytes (self ):
268261 'Verify the pretty-printing of bytes'
@@ -320,9 +313,9 @@ def test_sets(self):
320313 'Verify the pretty-printing of sets'
321314 if (gdb_major_version , gdb_minor_version ) < (7 , 3 ):
322315 self .skipTest ("pretty-printing of sets needs gdb 7.3 or later" )
323- self .assertGdbRepr (set ())
324- self .assertGdbRepr (set (['a' , 'b' ]))
325- self .assertGdbRepr (set ([4 , 5 , 6 ]))
316+ self .assertGdbRepr (set (), 'set()' )
317+ self .assertGdbRepr (set (['a' , 'b' ]), "{'a', 'b'}" )
318+ self .assertGdbRepr (set ([4 , 5 , 6 ]), "{4, 5, 6}" )
326319
327320 # Ensure that we handle sets containing the "dummy" key value,
328321 # which happens on deletion:
@@ -335,9 +328,9 @@ def test_frozensets(self):
335328 'Verify the pretty-printing of frozensets'
336329 if (gdb_major_version , gdb_minor_version ) < (7 , 3 ):
337330 self .skipTest ("pretty-printing of frozensets needs gdb 7.3 or later" )
338- self .assertGdbRepr (frozenset ())
339- self .assertGdbRepr (frozenset (['a' , 'b' ]))
340- self .assertGdbRepr (frozenset ([4 , 5 , 6 ]))
331+ self .assertGdbRepr (frozenset (), 'frozenset()' )
332+ self .assertGdbRepr (frozenset (['a' , 'b' ]), "frozenset({'a', 'b'})" )
333+ self .assertGdbRepr (frozenset ([4 , 5 , 6 ]), "frozenset({4, 5, 6})" )
341334
342335 def test_exceptions (self ):
343336 # Test a RuntimeError
0 commit comments