Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a282825b
Commit
a282825b
authored
Nov 21, 2013
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19183: Simplify test_gdb
repr() is no more platform dependent, SipHash has been fixed
parent
f4fd257a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
27 deletions
+20
-27
Lib/test/test_gdb.py
Lib/test/test_gdb.py
+20
-27
No files found.
Lib/test/test_gdb.py
View file @
a282825b
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment