diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-11-21 09:25:09 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-11-21 09:25:09 (GMT) |
commit | a282825bf6fae1f0d492df8a6ced15df4fa94222 (patch) | |
tree | 9f9fe2fc6b7482a15430ec2529f7288b0f53b6d8 | |
parent | f4fd257a028e22ab97e226ffd73715e9cead8eff (diff) | |
download | cpython-a282825bf6fae1f0d492df8a6ced15df4fa94222.zip cpython-a282825bf6fae1f0d492df8a6ced15df4fa94222.tar.gz cpython-a282825bf6fae1f0d492df8a6ced15df4fa94222.tar.bz2 |
Issue #19183: Simplify test_gdb
repr() is no more platform dependent, SipHash has been fixed
-rw-r--r-- | Lib/test/test_gdb.py | 47 |
1 files changed, 20 insertions, 27 deletions
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py index daf89bb..2cd17de 100644 --- a/Lib/test/test_gdb.py +++ b/Lib/test/test_gdb.py @@ -221,48 +221,41 @@ class PrettyPrintTests(DebuggerTests): gdb_output = self.get_stack_trace('id(42)') self.assertTrue(BREAKPOINT_FN in gdb_output) - def get_python_repr(self, val): - args = [sys.executable, '-c', 'print(repr(%a))' % (val,)] - env = os.environ.copy() - env['PYTHONHASHSEED'] = PYTHONHASHSEED - output = subprocess.check_output(args, env=env, universal_newlines=True) - return output.rstrip() - def assertGdbRepr(self, val, exp_repr=None, cmds_after_breakpoint=None): # Ensure that gdb's rendering of the value in a debugged process # matches repr(value) in this process: gdb_repr, gdb_output = self.get_gdb_repr('id(' + ascii(val) + ')', cmds_after_breakpoint) if not exp_repr: - exp_repr = self.get_python_repr(val) + exp_repr = repr(val) self.assertEqual(gdb_repr, exp_repr, ('%r did not equal expected %r; full output was:\n%s' % (gdb_repr, exp_repr, gdb_output))) def test_int(self): 'Verify the pretty-printing of various int values' - self.assertGdbRepr(42, '42') - self.assertGdbRepr(0, '0') - self.assertGdbRepr(-7, '-7') - self.assertGdbRepr(1000000000000, '1000000000000') - self.assertGdbRepr(-1000000000000000, '-1000000000000000') + self.assertGdbRepr(42) + self.assertGdbRepr(0) + self.assertGdbRepr(-7) + self.assertGdbRepr(1000000000000) + self.assertGdbRepr(-1000000000000000) def test_singletons(self): 'Verify the pretty-printing of True, False and None' - self.assertGdbRepr(True, 'True') - self.assertGdbRepr(False, 'False') - self.assertGdbRepr(None, 'None') + self.assertGdbRepr(True) + self.assertGdbRepr(False) + self.assertGdbRepr(None) def test_dicts(self): 'Verify the pretty-printing of dictionaries' - self.assertGdbRepr({}, '{}') - self.assertGdbRepr({'foo': 'bar'}) - self.assertGdbRepr({'foo': 'bar', 'douglas': 42}) + self.assertGdbRepr({}) + self.assertGdbRepr({'foo': 'bar'}, "{'foo': 'bar'}") + self.assertGdbRepr({'foo': 'bar', 'douglas': 42}, "{'douglas': 42, 'foo': 'bar'}") def test_lists(self): 'Verify the pretty-printing of lists' - self.assertGdbRepr([], '[]') - self.assertGdbRepr(list(range(5)), '[0, 1, 2, 3, 4]') + self.assertGdbRepr([]) + self.assertGdbRepr(list(range(5))) def test_bytes(self): 'Verify the pretty-printing of bytes' @@ -320,9 +313,9 @@ class PrettyPrintTests(DebuggerTests): 'Verify the pretty-printing of sets' if (gdb_major_version, gdb_minor_version) < (7, 3): self.skipTest("pretty-printing of sets needs gdb 7.3 or later") - self.assertGdbRepr(set()) - self.assertGdbRepr(set(['a', 'b'])) - self.assertGdbRepr(set([4, 5, 6])) + self.assertGdbRepr(set(), 'set()') + self.assertGdbRepr(set(['a', 'b']), "{'a', 'b'}") + self.assertGdbRepr(set([4, 5, 6]), "{4, 5, 6}") # Ensure that we handle sets containing the "dummy" key value, # which happens on deletion: @@ -335,9 +328,9 @@ id(s)''') 'Verify the pretty-printing of frozensets' if (gdb_major_version, gdb_minor_version) < (7, 3): self.skipTest("pretty-printing of frozensets needs gdb 7.3 or later") - self.assertGdbRepr(frozenset()) - self.assertGdbRepr(frozenset(['a', 'b'])) - self.assertGdbRepr(frozenset([4, 5, 6])) + self.assertGdbRepr(frozenset(), 'frozenset()') + self.assertGdbRepr(frozenset(['a', 'b']), "frozenset({'a', 'b'})") + self.assertGdbRepr(frozenset([4, 5, 6]), "frozenset({4, 5, 6})") def test_exceptions(self): # Test a RuntimeError |