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
6960c1a9
Kaydet (Commit)
6960c1a9
authored
Tem 11, 2014
tarafından
Berker Peksag
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #21906: Merge from 3.4.
üst
d8089e0d
7aee3ecd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
12 deletions
+76
-12
test_tools.py
Lib/test/test_tools.py
+67
-9
NEWS
Misc/NEWS
+3
-0
md5sum.py
Tools/scripts/md5sum.py
+6
-3
No files found.
Lib/test/test_tools.py
Dosyayı görüntüle @
6960c1a9
...
...
@@ -16,7 +16,7 @@ import sysconfig
import
tempfile
import
textwrap
from
test
import
support
from
test.script_helper
import
assert_python_ok
,
temp_dir
from
test.script_helper
import
assert_python_ok
,
assert_python_failure
if
not
sysconfig
.
is_python_build
():
# XXX some installers do contain the tools, should we detect that
...
...
@@ -61,7 +61,7 @@ class PindentTests(unittest.TestCase):
def
test_selftest
(
self
):
self
.
maxDiff
=
None
with
temp_dir
()
as
directory
:
with
support
.
temp_dir
()
as
directory
:
data_path
=
os
.
path
.
join
(
directory
,
'_test.py'
)
with
open
(
self
.
script
)
as
f
:
closed
=
f
.
read
()
...
...
@@ -367,7 +367,7 @@ class TestSundryScripts(unittest.TestCase):
# added for a script it should be added to the whitelist below.
# scripts that have independent tests.
whitelist
=
[
'reindent.py'
,
'pdeps.py'
,
'gprof2html'
]
whitelist
=
[
'reindent.py'
,
'pdeps.py'
,
'gprof2html'
,
'md5sum.py'
]
# scripts that can't be imported without running
blacklist
=
[
'make_ctype.py'
]
# scripts that use windows-only modules
...
...
@@ -450,16 +450,74 @@ class Gprof2htmlTests(unittest.TestCase):
self
.
assertTrue
(
wmock
.
open
.
called
)
class
MD5SumTests
(
unittest
.
TestCase
):
@classmethod
def
setUpClass
(
cls
):
cls
.
script
=
os
.
path
.
join
(
scriptsdir
,
'md5sum.py'
)
os
.
mkdir
(
support
.
TESTFN
)
cls
.
fodder
=
os
.
path
.
join
(
support
.
TESTFN
,
'md5sum.fodder'
)
with
open
(
cls
.
fodder
,
'wb'
)
as
f
:
f
.
write
(
b
'md5sum
\r\n
test file
\r\n
'
)
cls
.
fodder_md5
=
b
'd38dae2eb1ab346a292ef6850f9e1a0d'
cls
.
fodder_textmode_md5
=
b
'a8b07894e2ca3f2a4c3094065fa6e0a5'
@classmethod
def
tearDownClass
(
cls
):
support
.
rmtree
(
support
.
TESTFN
)
def
test_noargs
(
self
):
rc
,
out
,
err
=
assert_python_ok
(
self
.
script
)
self
.
assertEqual
(
rc
,
0
)
self
.
assertTrue
(
out
.
startswith
(
b
'd41d8cd98f00b204e9800998ecf8427e <stdin>'
))
self
.
assertFalse
(
err
)
def
test_checksum_fodder
(
self
):
rc
,
out
,
err
=
assert_python_ok
(
self
.
script
,
self
.
fodder
)
self
.
assertEqual
(
rc
,
0
)
self
.
assertTrue
(
out
.
startswith
(
self
.
fodder_md5
))
for
part
in
self
.
fodder
.
split
(
os
.
path
.
sep
):
self
.
assertIn
(
part
.
encode
(),
out
)
self
.
assertFalse
(
err
)
def
test_dash_l
(
self
):
rc
,
out
,
err
=
assert_python_ok
(
self
.
script
,
'-l'
,
self
.
fodder
)
self
.
assertEqual
(
rc
,
0
)
self
.
assertIn
(
self
.
fodder_md5
,
out
)
parts
=
self
.
fodder
.
split
(
os
.
path
.
sep
)
self
.
assertIn
(
parts
[
-
1
]
.
encode
(),
out
)
self
.
assertNotIn
(
parts
[
-
2
]
.
encode
(),
out
)
def
test_dash_t
(
self
):
rc
,
out
,
err
=
assert_python_ok
(
self
.
script
,
'-t'
,
self
.
fodder
)
self
.
assertEqual
(
rc
,
0
)
self
.
assertTrue
(
out
.
startswith
(
self
.
fodder_textmode_md5
))
self
.
assertNotIn
(
self
.
fodder_md5
,
out
)
def
test_dash_s
(
self
):
rc
,
out
,
err
=
assert_python_ok
(
self
.
script
,
'-s'
,
'512'
,
self
.
fodder
)
self
.
assertEqual
(
rc
,
0
)
self
.
assertIn
(
self
.
fodder_md5
,
out
)
def
test_multiple_files
(
self
):
rc
,
out
,
err
=
assert_python_ok
(
self
.
script
,
self
.
fodder
,
self
.
fodder
)
self
.
assertEqual
(
rc
,
0
)
lines
=
out
.
splitlines
()
self
.
assertEqual
(
len
(
lines
),
2
)
self
.
assertEqual
(
*
lines
)
def
test_usage
(
self
):
rc
,
out
,
err
=
assert_python_failure
(
self
.
script
,
'-h'
)
self
.
assertEqual
(
rc
,
2
)
self
.
assertEqual
(
out
,
b
''
)
self
.
assertGreater
(
err
,
b
''
)
# Run the tests in Tools/parser/test_unparse.py
with
support
.
DirsOnSysPath
(
os
.
path
.
join
(
basepath
,
'parser'
)):
from
test_unparse
import
UnparseTestCase
from
test_unparse
import
DirectoryTestCase
def
test_main
():
support
.
run_unittest
(
*
[
obj
for
obj
in
globals
()
.
values
()
if
isinstance
(
obj
,
type
)])
if
__name__
==
'__main__'
:
unittest
.
main
()
Misc/NEWS
Dosyayı görüntüle @
6960c1a9
...
...
@@ -752,6 +752,9 @@ Tests
Tools
/
Demos
-----------
-
Issue
#
21906
:
Make
Tools
/
scripts
/
md5sum
.
py
work
in
Python
3.
Patch
by
Zachary
Ware
.
-
Issue
#
21629
:
Fix
Argument
Clinic
's "--converters" feature.
- Add support for ``yield from`` to 2to3.
...
...
Tools/scripts/md5sum.py
Dosyayı görüntüle @
6960c1a9
...
...
@@ -9,7 +9,7 @@ fnfilter = None
rmode
=
'rb'
usage
=
"""
usage:
sum5
[-b] [-t] [-l] [-s bufsize] [file ...]
usage:
md5sum.py
[-b] [-t] [-l] [-s bufsize] [file ...]
-b : read files in binary mode (default)
-t : read files in text mode (you almost certainly don't want this!)
-l : print last pathname component only
...
...
@@ -17,6 +17,7 @@ usage: sum5 [-b] [-t] [-l] [-s bufsize] [file ...]
file ... : files to sum; '-' or no files means stdin
"""
%
bufsize
import
io
import
sys
import
os
import
getopt
...
...
@@ -24,7 +25,7 @@ from hashlib import md5
def
sum
(
*
files
):
sts
=
0
if
files
and
isinstance
(
files
[
-
1
],
fil
e
):
if
files
and
isinstance
(
files
[
-
1
],
io
.
IOBas
e
):
out
,
files
=
files
[
-
1
],
files
[:
-
1
]
else
:
out
=
sys
.
stdout
...
...
@@ -53,12 +54,14 @@ def printsum(filename, out=sys.stdout):
return
sts
def
printsumfp
(
fp
,
filename
,
out
=
sys
.
stdout
):
m
=
md5
.
new
()
m
=
md5
()
try
:
while
1
:
data
=
fp
.
read
(
bufsize
)
if
not
data
:
break
if
isinstance
(
data
,
str
):
data
=
data
.
encode
(
fp
.
encoding
)
m
.
update
(
data
)
except
IOError
as
msg
:
sys
.
stderr
.
write
(
'
%
s: I/O error:
%
s
\n
'
%
(
filename
,
msg
))
...
...
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