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
1e17d4aa
Commit
1e17d4aa
authored
Jan 30, 2018
by
Benjamin Peterson
Committed by
GitHub
Jan 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compare with difflib not diff(1) (GH-5450)
parent
8c9bb72e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
Lib/lib2to3/tests/test_parser.py
Lib/lib2to3/tests/test_parser.py
+9
-13
No files found.
Lib/lib2to3/tests/test_parser.py
View file @
1e17d4aa
...
...
@@ -12,6 +12,7 @@ from .support import driver, driver_no_print_statement
from
test.support
import
verbose
# Python imports
import
difflib
import
importlib
import
operator
import
os
...
...
@@ -429,8 +430,8 @@ class TestParserIdempotency(support.TestCase):
except
ParseError
as
err
:
self
.
fail
(
'ParseError on file %s (%s)'
%
(
filepath
,
err
))
new
=
str
(
tree
)
x
=
diff
(
filepath
,
new
,
encoding
=
encoding
)
if
x
:
if
new
!=
source
:
print
(
diff_texts
(
source
,
new
,
filepath
))
self
.
fail
(
"Idempotency failed: %s"
%
filepath
)
def
test_extended_unpacking
(
self
):
...
...
@@ -480,17 +481,12 @@ class TestGeneratorExpressions(GrammarTest):
self
.
validate
(
"set(x for x in [],)"
)
def
diff
(
fn
,
result
,
encoding
=
'utf-8'
):
try
:
with
open
(
'@'
,
'w'
,
encoding
=
encoding
,
newline
=
'
\
n
'
)
as
f
:
f
.
write
(
str
(
result
))
fn
=
fn
.
replace
(
'"'
,
'
\
\
"'
)
return
subprocess
.
call
([
'diff'
,
'-u'
,
fn
,
'@'
],
stdout
=
(
subprocess
.
DEVNULL
if
verbose
<
1
else
None
))
finally
:
try
:
os
.
remove
(
"@"
)
except
OSError
:
pass
def
diff_texts
(
a
,
b
,
filename
):
a
=
a
.
splitlines
()
b
=
b
.
splitlines
()
return
difflib
.
unified_diff
(
a
,
b
,
filename
,
filename
,
"(original)"
,
"(reserialized)"
,
lineterm
=
""
)
if
__name__
==
'__main__'
:
...
...
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