[Python-checkins] cpython: Issue #19183: Simplify test_gdb

victor.stinner python-checkins at python.org
Thu Nov 21 10:29:52 CET 2013


http://hg.python.org/cpython/rev/eec4758e3a45
changeset:   87307:eec4758e3a45
parent:      87305:7cf7f19445ba
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Nov 21 10:25:09 2013 +0100
summary:
  Issue #19183: Simplify test_gdb

repr() is no more platform dependent, SipHash has been fixed

files:
  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
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -221,48 +221,41 @@
         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 @@
         '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 @@
         '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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list