Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
33b24f5c
Kaydet (Commit)
33b24f5c
authored
Haz 28, 2015
tarafından
Jason R. Coombs
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20387: Backport test from Python 3.4
üst
84af51d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
test_tokenize.py
Lib/test/test_tokenize.py
+19
-1
No files found.
Lib/test/test_tokenize.py
Dosyayı görüntüle @
33b24f5c
...
...
@@ -559,7 +559,7 @@ Pathological whitespace (http://bugs.python.org/issue16152)
from
test
import
test_support
from
tokenize
import
(
untokenize
,
generate_tokens
,
NUMBER
,
NAME
,
OP
,
STRING
,
ENDMARKER
,
tok_name
,
Untokenizer
)
STRING
,
ENDMARKER
,
tok_name
,
Untokenizer
,
tokenize
)
from
StringIO
import
StringIO
import
os
from
unittest
import
TestCase
...
...
@@ -650,12 +650,30 @@ class UntokenizeTest(TestCase):
self
.
assertEqual
(
u
.
untokenize
(
iter
([
token
])),
'Hello '
)
class
TestRoundtrip
(
TestCase
):
def
roundtrip
(
self
,
code
):
if
isinstance
(
code
,
str
):
code
=
code
.
encode
(
'utf-8'
)
tokens
=
generate_tokens
(
StringIO
(
code
)
.
readline
)
return
untokenize
(
tokens
)
.
decode
(
'utf-8'
)
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
=
self
.
roundtrip
(
code
)
.
split
(
'
\n
'
)
self
.
assertEqual
(
codelines
[
1
],
codelines
[
2
])
__test__
=
{
"doctests"
:
doctests
,
'decistmt'
:
decistmt
}
def
test_main
():
from
test
import
test_tokenize
test_support
.
run_doctest
(
test_tokenize
,
True
)
test_support
.
run_unittest
(
UntokenizeTest
)
test_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