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
5713b3c5
Commit
5713b3c5
authored
Jun 20, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #20387: Add test capturing failure to roundtrip indented code in tokenize module.
parent
7cf36387
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
Lib/test/test_tokenize.py
Lib/test/test_tokenize.py
+17
-0
No files found.
Lib/test/test_tokenize.py
View file @
5713b3c5
...
...
@@ -1229,6 +1229,22 @@ class UntokenizeTest(TestCase):
self
.
assertEqual
(
untokenize
(
iter
(
tokens
)),
b'Hello '
)
class
TestRoundtrip
(
TestCase
):
def
roundtrip
(
self
,
code
):
if
isinstance
(
code
,
str
):
code
=
code
.
encode
(
'utf-8'
)
return
untokenize
(
tokenize
(
BytesIO
(
code
).
readline
))
def
test_indentation_semantics_retained
(
self
):
"""
Ensure that although whitespace might be mutated in a roundtrip,
the semantic meaning of the indentation remains consistent.
"""
code
=
"if False:
\
n
\
t
x=3
\
n
\
t
x=3
\
n
"
codelines
=
roundtrip
(
code
).
split
(
'
\
n
'
)
self
.
assertEqual
(
codelines
[
1
],
codelines
[
2
])
__test__
=
{
"doctests"
:
doctests
,
'decistmt'
:
decistmt
}
def
test_main
():
...
...
@@ -1239,6 +1255,7 @@ def test_main():
support
.
run_unittest
(
TestDetectEncoding
)
support
.
run_unittest
(
TestTokenize
)
support
.
run_unittest
(
UntokenizeTest
)
support
.
run_unittest
(
TestRoundtrip
)
if
__name__
==
"__main__"
:
test_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