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
a441287f
Commit
a441287f
authored
Jun 05, 2010
by
Michael Foord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract error message truncating into a method (unittest.TestCase._truncateMessage).
parent
0100702b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
Lib/unittest/case.py
Lib/unittest/case.py
+6
-4
No files found.
Lib/unittest/case.py
View file @
a441287f
...
...
@@ -690,13 +690,15 @@ class TestCase(object):
diffMsg
=
'
\
n
'
+
'
\
n
'
.
join
(
difflib
.
ndiff
(
pprint
.
pformat
(
seq1
).
splitlines
(),
pprint
.
pformat
(
seq2
).
splitlines
()))
if
max_diff
is
None
or
len
(
diffMsg
)
<=
max_diff
:
standardMsg
+=
diffMsg
else
:
standardMsg
+=
diffMsg
[:
max_diff
]
+
TRUNCATED_DIFF
standardMsg
=
self
.
_truncateMessage
(
standardMsg
,
diffMsg
,
max_diff
)
msg
=
self
.
_formatMessage
(
msg
,
standardMsg
)
self
.
fail
(
msg
)
def
_truncateMessage
(
self
,
message
,
diff
,
max_diff
):
if
max_diff
is
None
or
len
(
diff
)
<=
max_diff
:
return
message
+
diff
return
message
+
diff
[:
max_diff
]
+
TRUNCATED_DIFF
def
assertListEqual
(
self
,
list1
,
list2
,
msg
=
None
):
"""A list-specific equality assertion.
...
...
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