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
f08fea9e
Kaydet (Commit)
f08fea9e
authored
Eyl 02, 2015
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 24297: Fix test_symbol on Windows
Don't rely on end of line. Open files in text mode, not in binary mode.
üst
8aad8d6a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
test_symbol.py
Lib/test/test_symbol.py
+21
-14
No files found.
Lib/test/test_symbol.py
Dosyayı görüntüle @
f08fea9e
...
...
@@ -15,12 +15,11 @@ TEST_PY_FILE = 'symbol_test.py'
class
TestSymbolGeneration
(
unittest
.
TestCase
):
def
_copy_file_without_generated_symbols
(
self
,
source_file
,
dest_file
):
with
open
(
source_file
,
'rb'
)
as
fp
:
with
open
(
source_file
)
as
fp
:
lines
=
fp
.
readlines
()
nl
=
lines
[
0
][
len
(
lines
[
0
]
.
rstrip
()):]
with
open
(
dest_file
,
'wb'
)
as
fp
:
fp
.
writelines
(
lines
[:
lines
.
index
(
b
"#--start constants--"
+
nl
)
+
1
])
fp
.
writelines
(
lines
[
lines
.
index
(
b
"#--end constants--"
+
nl
):])
with
open
(
dest_file
,
'w'
)
as
fp
:
fp
.
writelines
(
lines
[:
lines
.
index
(
"#--start constants--
\n
"
)
+
1
])
fp
.
writelines
(
lines
[
lines
.
index
(
"#--end constants--
\n
"
):])
def
_generate_symbols
(
self
,
grammar_file
,
target_symbol_py_file
):
proc
=
subprocess
.
Popen
([
sys
.
executable
,
...
...
@@ -30,18 +29,26 @@ class TestSymbolGeneration(unittest.TestCase):
stderr
=
proc
.
communicate
()[
1
]
return
proc
.
returncode
,
stderr
def
compare_files
(
self
,
file1
,
file2
):
with
open
(
file1
)
as
fp
:
lines1
=
fp
.
readlines
()
with
open
(
file2
)
as
fp
:
lines2
=
fp
.
readlines
()
self
.
assertEqual
(
lines1
,
lines2
)
@unittest.skipIf
(
not
os
.
path
.
exists
(
GRAMMAR_FILE
),
'test only works from source build directory'
)
def
test_real_grammar_and_symbol_file
(
self
):
self
.
_copy_file_without_generated_symbols
(
SYMBOL_FILE
,
TEST_PY_FILE
)
self
.
addCleanup
(
support
.
unlink
,
TEST_PY_FILE
)
self
.
assertFalse
(
filecmp
.
cmp
(
SYMBOL_FILE
,
TEST_PY_FILE
))
self
.
assertEqual
((
0
,
b
''
),
self
.
_generate_symbols
(
GRAMMAR_FILE
,
TEST_PY_FILE
))
self
.
assertTrue
(
filecmp
.
cmp
(
SYMBOL_FILE
,
TEST_PY_FILE
),
'symbol stat:
%
r
\n
test_py stat:
%
r
\n
'
%
(
os
.
stat
(
SYMBOL_FILE
),
os
.
stat
(
TEST_PY_FILE
)))
output
=
support
.
TESTFN
self
.
addCleanup
(
support
.
unlink
,
output
)
self
.
_copy_file_without_generated_symbols
(
SYMBOL_FILE
,
output
)
exitcode
,
stderr
=
self
.
_generate_symbols
(
GRAMMAR_FILE
,
output
)
self
.
assertEqual
(
b
''
,
stderr
)
self
.
assertEqual
(
0
,
exitcode
)
self
.
compare_files
(
SYMBOL_FILE
,
output
)
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