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
229011d9
Kaydet (Commit)
229011d9
authored
Eyl 18, 2011
tarafından
Éric Araujo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make a number of small changes to ease the backport to distutils2
üst
41479450
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
104 additions
and
125 deletions
+104
-125
build_clib.py
Lib/packaging/command/build_clib.py
+1
-2
upload_docs.py
Lib/packaging/command/upload_docs.py
+1
-0
unixccompiler.py
Lib/packaging/compiler/unixccompiler.py
+1
-1
database.py
Lib/packaging/database.py
+4
-3
__init__.py
Lib/packaging/tests/__init__.py
+5
-8
__main__.py
Lib/packaging/tests/__main__.py
+2
-0
pypi_server.py
Lib/packaging/tests/pypi_server.py
+4
-3
test_command_build_ext.py
Lib/packaging/tests/test_command_build_ext.py
+1
-1
test_command_install_lib.py
Lib/packaging/tests/test_command_install_lib.py
+1
-1
test_command_upload.py
Lib/packaging/tests/test_command_upload.py
+10
-14
test_command_upload_docs.py
Lib/packaging/tests/test_command_upload_docs.py
+28
-37
test_create.py
Lib/packaging/tests/test_create.py
+8
-5
test_database.py
Lib/packaging/tests/test_database.py
+3
-2
test_depgraph.py
Lib/packaging/tests/test_depgraph.py
+17
-16
test_dist.py
Lib/packaging/tests/test_dist.py
+6
-4
test_install.py
Lib/packaging/tests/test_install.py
+1
-1
test_pypi_server.py
Lib/packaging/tests/test_pypi_server.py
+8
-7
test_run.py
Lib/packaging/tests/test_run.py
+1
-16
test_util.py
Lib/packaging/tests/test_util.py
+2
-4
No files found.
Lib/packaging/command/build_clib.py
Dosyayı görüntüle @
229011d9
...
...
@@ -16,7 +16,7 @@ distribution and needed by extension modules.
import
os
from
packaging.command.cmd
import
Command
from
packaging.errors
import
PackagingSetupError
from
packaging.compiler
import
customize_compiler
from
packaging.compiler
import
customize_compiler
,
new_compiler
from
packaging
import
logger
...
...
@@ -93,7 +93,6 @@ class build_clib(Command):
return
# Yech -- this is cut 'n pasted from build_ext.py!
from
packaging.compiler
import
new_compiler
self
.
compiler
=
new_compiler
(
compiler
=
self
.
compiler
,
dry_run
=
self
.
dry_run
,
force
=
self
.
force
)
...
...
Lib/packaging/command/upload_docs.py
Dosyayı görüntüle @
229011d9
...
...
@@ -87,6 +87,7 @@ class upload_docs(Command):
content_type
,
body
=
encode_multipart
(
fields
,
files
)
credentials
=
self
.
username
+
':'
+
self
.
password
# FIXME should use explicit encoding
auth
=
b
"Basic "
+
base64
.
encodebytes
(
credentials
.
encode
())
.
strip
()
logger
.
info
(
"Submitting documentation to
%
s"
,
self
.
repository
)
...
...
Lib/packaging/compiler/unixccompiler.py
Dosyayı görüntüle @
229011d9
...
...
@@ -127,7 +127,7 @@ class UnixCCompiler(CCompiler):
executables
[
'ranlib'
]
=
[
"ranlib"
]
# Needed for the filename generation methods provided by the base
# class, CCompiler.
NB.
whoever instantiates/uses a particular
# class, CCompiler.
XXX
whoever instantiates/uses a particular
# UnixCCompiler instance should set 'shared_lib_ext' -- we set a
# reasonable common default here, but it's not necessarily used on all
# Unices!
...
...
Lib/packaging/database.py
Dosyayı görüntüle @
229011d9
"""PEP 376 implementation."""
import
io
import
os
import
re
import
csv
import
sys
import
zipimport
from
io
import
StringIO
from
hashlib
import
md5
from
packaging
import
logger
from
packaging.errors
import
PackagingError
from
packaging.version
import
suggest_normalized_version
,
VersionPredicate
...
...
@@ -173,7 +174,7 @@ class Distribution:
def
get_resource_path
(
self
,
relative_path
):
with
self
.
get_distinfo_file
(
'RESOURCES'
)
as
resources_file
:
resources_reader
=
csv
.
reader
(
resources_file
,
delimiter
=
','
,
lineterminator
=
'
\n
'
)
lineterminator
=
'
\n
'
)
for
relative
,
destination
in
resources_reader
:
if
relative
==
relative_path
:
return
destination
...
...
@@ -334,7 +335,7 @@ class EggInfoDistribution:
else
:
# FIXME handle the case where zipfile is not available
zipf
=
zipimport
.
zipimporter
(
path
)
fileobj
=
io
.
StringIO
(
fileobj
=
StringIO
(
zipf
.
get_data
(
'EGG-INFO/PKG-INFO'
)
.
decode
(
'utf8'
))
self
.
metadata
=
Metadata
(
fileobj
=
fileobj
)
try
:
...
...
Lib/packaging/tests/__init__.py
Dosyayı görüntüle @
229011d9
...
...
@@ -6,17 +6,15 @@ packaging.tests package. Each test module has a name starting with
to return an initialized unittest.TestSuite instance.
Utility code is included in packaging.tests.support.
"""
# Put this text back for the backport
#Always import unittest from this module, it will be the right version
#(standard library unittest for 3.2 and higher, third-party unittest2
#elease for older versions).
Always import unittest from this module: it will be unittest from the
standard library for packaging tests and unittest2 for distutils2 tests.
"""
import
os
import
sys
import
unittest
from
test.support
import
TESTFN
from
io
import
StringIO
# XXX move helpers to support, add tests for them, remove things that
# duplicate test.support (or keep them for the backport; needs thinking)
...
...
@@ -115,9 +113,8 @@ def reap_children():
def
captured_stdout
(
func
,
*
args
,
**
kw
):
import
io
orig_stdout
=
getattr
(
sys
,
'stdout'
)
setattr
(
sys
,
'stdout'
,
io
.
StringIO
())
setattr
(
sys
,
'stdout'
,
StringIO
())
try
:
res
=
func
(
*
args
,
**
kw
)
sys
.
stdout
.
seek
(
0
)
...
...
Lib/packaging/tests/__main__.py
Dosyayı görüntüle @
229011d9
...
...
@@ -14,6 +14,8 @@ def test_main():
start_dir
=
os
.
path
.
dirname
(
__file__
)
top_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
start_dir
))
test_loader
=
unittest
.
TestLoader
()
# XXX find out how to use unittest.main, to get command-line options
# (failfast, catch, etc.)
run_unittest
(
test_loader
.
discover
(
start_dir
,
top_level_dir
=
top_dir
))
finally
:
reap_children
()
...
...
Lib/packaging/tests/pypi_server.py
Dosyayı görüntüle @
229011d9
...
...
@@ -40,6 +40,7 @@ from xmlrpc.server import SimpleXMLRPCServer
from
packaging.tests
import
unittest
PYPI_DEFAULT_STATIC_PATH
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'pypiserver'
)
...
...
@@ -219,7 +220,7 @@ class PyPIRequestHandler(SimpleHTTPRequestHandler):
relative_path
+=
"index.html"
if
relative_path
.
endswith
(
'.tar.gz'
):
with
open
(
fs_path
+
relative_path
,
'
br
'
)
as
file
:
with
open
(
fs_path
+
relative_path
,
'
rb
'
)
as
file
:
data
=
file
.
read
()
headers
=
[(
'Content-type'
,
'application/x-gtar'
)]
else
:
...
...
@@ -260,8 +261,8 @@ class PyPIRequestHandler(SimpleHTTPRequestHandler):
self
.
send_header
(
header
,
value
)
self
.
end_headers
()
if
type
(
data
)
is
str
:
data
=
data
.
encode
()
if
isinstance
(
data
,
str
)
:
data
=
data
.
encode
(
'utf-8'
)
self
.
wfile
.
write
(
data
)
...
...
Lib/packaging/tests/test_command_build_ext.py
Dosyayı görüntüle @
229011d9
...
...
@@ -4,6 +4,7 @@ import site
import
sysconfig
import
textwrap
from
io
import
StringIO
from
sysconfig
import
_CONFIG_VARS
from
packaging.dist
import
Distribution
from
packaging.errors
import
(
UnknownFileError
,
CompileError
,
PackagingPlatformError
)
...
...
@@ -78,7 +79,6 @@ class BuildExtTestCase(support.TempdirManager,
old
=
sys
.
platform
sys
.
platform
=
'sunos'
# fooling finalize_options
from
sysconfig
import
_CONFIG_VARS
old_var
=
_CONFIG_VARS
.
get
(
'Py_ENABLE_SHARED'
)
_CONFIG_VARS
[
'Py_ENABLE_SHARED'
]
=
1
...
...
Lib/packaging/tests/test_command_install_lib.py
Dosyayı görüntüle @
229011d9
...
...
@@ -40,7 +40,7 @@ class InstallLibTestCase(support.TempdirManager,
cmd
.
finalize_options
()
self
.
assertEqual
(
cmd
.
optimize
,
2
)
@unittest.skipIf
(
no_bytecode
,
'byte-compile
not support
ed'
)
@unittest.skipIf
(
no_bytecode
,
'byte-compile
disabl
ed'
)
def
test_byte_compile
(
self
):
pkg_dir
,
dist
=
self
.
create_dist
()
cmd
=
install_lib
(
dist
)
...
...
Lib/packaging/tests/test_command_upload.py
Dosyayı görüntüle @
229011d9
"""Tests for packaging.command.upload."""
import
os
import
sys
from
packaging.command.upload
import
upload
from
packaging.dist
import
Distribution
...
...
@@ -103,22 +102,23 @@ class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
command
,
pyversion
,
filename
=
'xxx'
,
'3.3'
,
path
dist_files
=
[(
command
,
pyversion
,
filename
)]
# lets run it
pkg_dir
,
dist
=
self
.
create_dist
(
dist_files
=
dist_files
,
author
=
'dédé'
)
# let
'
s run it
dist
=
self
.
create_dist
(
dist_files
=
dist_files
,
author
=
'dédé'
)[
1
]
cmd
=
upload
(
dist
)
cmd
.
ensure_finalized
()
cmd
.
repository
=
self
.
pypi
.
full_address
cmd
.
run
()
# what did we send
?
# what did we send?
handler
,
request_data
=
self
.
pypi
.
requests
[
-
1
]
headers
=
handler
.
headers
#self.assertIn('dédé', str(request_data)
)
self
.
assertIn
(
'dédé'
.
encode
(
'utf-8'
),
request_data
)
self
.
assertIn
(
b
'xxx'
,
request_data
)
self
.
assertEqual
(
int
(
headers
[
'content-length'
]),
len
(
request_data
))
self
.
assertLess
(
int
(
headers
[
'content-length'
]),
2500
)
self
.
assertTrue
(
headers
[
'content-type'
]
.
startswith
(
'multipart/form-data'
))
self
.
assertTrue
(
headers
[
'content-type'
]
.
startswith
(
'multipart/form-data'
))
self
.
assertEqual
(
handler
.
command
,
'POST'
)
self
.
assertNotIn
(
'
\n
'
,
headers
[
'authorization'
])
...
...
@@ -132,20 +132,16 @@ class UploadTestCase(support.TempdirManager, support.EnvironRestorer,
self
.
write_file
(
os
.
path
.
join
(
docs_path
,
"index.html"
),
"yellow"
)
self
.
write_file
(
self
.
rc
,
PYPIRC
)
# lets run it
pkg_dir
,
dist
=
self
.
create_dist
(
dist_files
=
dist_files
,
author
=
'dédé'
)
# let
'
s run it
dist
=
self
.
create_dist
(
dist_files
=
dist_files
,
author
=
'dédé'
)[
1
]
cmd
=
upload
(
dist
)
cmd
.
get_finalized_command
(
"build"
)
.
run
()
cmd
.
upload_docs
=
True
cmd
.
ensure_finalized
()
cmd
.
repository
=
self
.
pypi
.
full_address
prev_dir
=
os
.
getcwd
()
try
:
os
.
chdir
(
self
.
tmp_dir
)
cmd
.
run
()
finally
:
os
.
chdir
(
prev_dir
)
os
.
chdir
(
self
.
tmp_dir
)
cmd
.
run
()
handler
,
request_data
=
self
.
pypi
.
requests
[
-
1
]
action
,
name
,
content
=
request_data
.
split
(
...
...
Lib/packaging/tests/test_command_upload_docs.py
Dosyayı görüntüle @
229011d9
"""Tests for packaging.command.upload_docs."""
import
os
import
sys
import
shutil
import
zipfile
try
:
...
...
@@ -52,34 +51,27 @@ class UploadDocsTestCase(support.TempdirManager,
def
test_default_uploaddir
(
self
):
sandbox
=
self
.
mkdtemp
()
previous
=
os
.
getcwd
()
os
.
chdir
(
sandbox
)
try
:
os
.
mkdir
(
"build"
)
self
.
prepare_sample_dir
(
"build"
)
self
.
cmd
.
ensure_finalized
()
self
.
assertEqual
(
self
.
cmd
.
upload_dir
,
os
.
path
.
join
(
"build"
,
"docs"
))
finally
:
os
.
chdir
(
previous
)
os
.
mkdir
(
"build"
)
self
.
prepare_sample_dir
(
"build"
)
self
.
cmd
.
ensure_finalized
()
self
.
assertEqual
(
self
.
cmd
.
upload_dir
,
os
.
path
.
join
(
"build"
,
"docs"
))
def
test_default_uploaddir_looks_for_doc_also
(
self
):
sandbox
=
self
.
mkdtemp
()
previous
=
os
.
getcwd
()
os
.
chdir
(
sandbox
)
try
:
os
.
mkdir
(
"build"
)
self
.
prepare_sample_dir
(
"build"
)
os
.
rename
(
os
.
path
.
join
(
"build"
,
"docs"
),
os
.
path
.
join
(
"build"
,
"doc"
))
self
.
cmd
.
ensure_finalized
()
self
.
assertEqual
(
self
.
cmd
.
upload_dir
,
os
.
path
.
join
(
"build"
,
"doc"
))
finally
:
os
.
chdir
(
previous
)
os
.
mkdir
(
"build"
)
self
.
prepare_sample_dir
(
"build"
)
os
.
rename
(
os
.
path
.
join
(
"build"
,
"docs"
),
os
.
path
.
join
(
"build"
,
"doc"
))
self
.
cmd
.
ensure_finalized
()
self
.
assertEqual
(
self
.
cmd
.
upload_dir
,
os
.
path
.
join
(
"build"
,
"doc"
))
def
prepare_sample_dir
(
self
,
sample_dir
=
None
):
if
sample_dir
is
None
:
sample_dir
=
self
.
mkdtemp
()
os
.
mkdir
(
os
.
path
.
join
(
sample_dir
,
"docs"
))
self
.
write_file
(
os
.
path
.
join
(
sample_dir
,
"docs"
,
"index.html"
),
"Ce mortel ennui"
)
self
.
write_file
(
os
.
path
.
join
(
sample_dir
,
"docs"
,
"index.html"
),
"Ce mortel ennui"
)
self
.
write_file
(
os
.
path
.
join
(
sample_dir
,
"index.html"
),
"Oh la la"
)
return
sample_dir
...
...
@@ -108,9 +100,8 @@ class UploadDocsTestCase(support.TempdirManager,
self
.
assertTrue
(
handler
.
headers
[
'content-type'
]
.
startswith
(
'multipart/form-data;'
))
action
,
name
,
version
,
content
=
\
request_data
.
split
(
"----------------GHSKFJDLGDS7543FJKLFHRE75642756743254"
.
encode
())[
1
:
5
]
action
,
name
,
version
,
content
=
request_data
.
split
(
b
'----------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
)[
1
:
5
]
# check that we picked the right chunks
self
.
assertIn
(
b
'name=":action"'
,
action
)
...
...
@@ -126,27 +117,25 @@ class UploadDocsTestCase(support.TempdirManager,
@unittest.skipIf
(
_ssl
is
None
,
'Needs SSL support'
)
def
test_https_connection
(
self
):
https_called
=
False
orig_https
=
upload_docs_mod
.
http
.
client
.
HTTPSConnection
self
.
https_called
=
False
self
.
addCleanup
(
setattr
,
upload_docs_mod
.
http
.
client
,
'HTTPSConnection'
,
upload_docs_mod
.
http
.
client
.
HTTPSConnection
)
def
https_conn_wrapper
(
*
args
):
nonlocal
https_called
https_called
=
True
self
.
https_called
=
True
# the testing server is http
return
upload_docs_mod
.
http
.
client
.
HTTPConnection
(
*
args
)
upload_docs_mod
.
http
.
client
.
HTTPSConnection
=
https_conn_wrapper
try
:
self
.
prepare_command
()
self
.
cmd
.
run
()
self
.
assertFalse
(
https_called
)
self
.
cmd
.
repository
=
self
.
cmd
.
repository
.
replace
(
"http"
,
"https"
)
self
.
cmd
.
run
()
self
.
assertTrue
(
https_called
)
finally
:
upload_docs_mod
.
http
.
client
.
HTTPSConnection
=
orig_https
self
.
prepare_command
()
self
.
cmd
.
run
()
self
.
assertFalse
(
self
.
https_called
)
self
.
cmd
.
repository
=
self
.
cmd
.
repository
.
replace
(
"http"
,
"https"
)
self
.
cmd
.
run
()
self
.
assertTrue
(
self
.
https_called
)
def
test_handling_response
(
self
):
self
.
pypi
.
default_response_status
=
'403 Forbidden'
...
...
@@ -155,7 +144,8 @@ class UploadDocsTestCase(support.TempdirManager,
self
.
assertIn
(
'Upload failed (403): Forbidden'
,
self
.
get_logs
()[
-
1
])
self
.
pypi
.
default_response_status
=
'301 Moved Permanently'
self
.
pypi
.
default_response_headers
.
append
((
"Location"
,
"brand_new_location"
))
self
.
pypi
.
default_response_headers
.
append
(
(
"Location"
,
"brand_new_location"
))
self
.
cmd
.
run
()
self
.
assertIn
(
'brand_new_location'
,
self
.
get_logs
()[
-
1
])
...
...
@@ -185,6 +175,7 @@ class UploadDocsTestCase(support.TempdirManager,
self
.
assertTrue
(
record
,
"should report the response"
)
self
.
assertIn
(
self
.
pypi
.
default_response_data
,
record
)
def
test_suite
():
return
unittest
.
makeSuite
(
UploadDocsTestCase
)
...
...
Lib/packaging/tests/test_create.py
Dosyayı görüntüle @
229011d9
"""Tests for packaging.create."""
import
io
import
os
import
sys
import
sysconfig
from
io
import
StringIO
from
textwrap
import
dedent
from
packaging.create
import
MainProgram
,
ask_yn
,
ask
,
main
...
...
@@ -20,8 +20,8 @@ class CreateTestCase(support.TempdirManager,
super
(
CreateTestCase
,
self
)
.
setUp
()
self
.
_stdin
=
sys
.
stdin
# TODO use Inputs
self
.
_stdout
=
sys
.
stdout
sys
.
stdin
=
io
.
StringIO
()
sys
.
stdout
=
io
.
StringIO
()
sys
.
stdin
=
StringIO
()
sys
.
stdout
=
StringIO
()
self
.
_cwd
=
os
.
getcwd
()
self
.
wdir
=
self
.
mkdtemp
()
os
.
chdir
(
self
.
wdir
)
...
...
@@ -135,7 +135,8 @@ class CreateTestCase(support.TempdirManager,
sys
.
stdin
.
seek
(
0
)
main
()
with
open
(
os
.
path
.
join
(
self
.
wdir
,
'setup.cfg'
),
encoding
=
'utf-8'
)
as
fp
:
path
=
os
.
path
.
join
(
self
.
wdir
,
'setup.cfg'
)
with
open
(
path
,
encoding
=
'utf-8'
)
as
fp
:
contents
=
fp
.
read
()
self
.
assertEqual
(
contents
,
dedent
(
"""
\
...
...
@@ -210,7 +211,9 @@ ho, baby!
sys
.
stdin
.
seek
(
0
)
# FIXME Out of memory error.
main
()
with
open
(
os
.
path
.
join
(
self
.
wdir
,
'setup.cfg'
),
encoding
=
'utf-8'
)
as
fp
:
path
=
os
.
path
.
join
(
self
.
wdir
,
'setup.cfg'
)
with
open
(
path
,
encoding
=
'utf-8'
)
as
fp
:
contents
=
fp
.
read
()
self
.
assertEqual
(
contents
,
dedent
(
"""
\
...
...
Lib/packaging/tests/test_database.py
Dosyayı görüntüle @
229011d9
...
...
@@ -49,8 +49,8 @@ class FakeDistsMixin:
# distributions
tmpdir
=
tempfile
.
mkdtemp
()
self
.
addCleanup
(
shutil
.
rmtree
,
tmpdir
)
self
.
fake_dists_path
=
os
.
path
.
join
(
tmpdir
,
'fake_dists'
)
self
.
fake_dists_path
=
os
.
path
.
realpath
(
self
.
fake_dists_path
)
self
.
fake_dists_path
=
os
.
path
.
realpath
(
os
.
path
.
join
(
tmpdir
,
'fake_dists'
)
)
fake_dists_src
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'fake_dists'
))
shutil
.
copytree
(
fake_dists_src
,
self
.
fake_dists_path
)
...
...
@@ -58,6 +58,7 @@ class FakeDistsMixin:
# back (to avoid getting a read-only copy of a read-only file). we
# could pass a custom copy_function to change the mode of files, but
# shutil gives no control over the mode of directories :(
# see http://bugs.python.org/issue1666318
for
root
,
dirs
,
files
in
os
.
walk
(
self
.
fake_dists_path
):
os
.
chmod
(
root
,
0
o755
)
for
f
in
files
:
...
...
Lib/packaging/tests/test_depgraph.py
Dosyayı görüntüle @
229011d9
"""Tests for packaging.depgraph """
import
io
import
os
import
re
import
sys
import
packaging.database
from
io
import
StringIO
from
packaging
import
depgraph
from
packaging.database
import
get_distribution
,
enable_cache
,
disable_cache
from
packaging.tests
import
unittest
,
support
from
packaging.tests.support
import
requires_zlib
...
...
@@ -30,13 +31,13 @@ class DepGraphTestCase(support.LoggingCatcher,
path
=
os
.
path
.
abspath
(
path
)
sys
.
path
.
insert
(
0
,
path
)
self
.
addCleanup
(
sys
.
path
.
remove
,
path
)
self
.
addCleanup
(
packaging
.
database
.
enable_cache
)
packaging
.
database
.
disable_cache
()
self
.
addCleanup
(
enable_cache
)
disable_cache
()
def
test_generate_graph
(
self
):
dists
=
[]
for
name
in
self
.
DISTROS_DIST
:
dist
=
packaging
.
database
.
get_distribution
(
name
)
dist
=
get_distribution
(
name
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
...
...
@@ -61,7 +62,7 @@ class DepGraphTestCase(support.LoggingCatcher,
def
test_generate_graph_egg
(
self
):
dists
=
[]
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
:
dist
=
packaging
.
database
.
get_distribution
(
name
,
use_egg_info
=
True
)
dist
=
get_distribution
(
name
,
use_egg_info
=
True
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
...
...
@@ -104,7 +105,7 @@ class DepGraphTestCase(support.LoggingCatcher,
def
test_dependent_dists
(
self
):
dists
=
[]
for
name
in
self
.
DISTROS_DIST
:
dist
=
packaging
.
database
.
get_distribution
(
name
)
dist
=
get_distribution
(
name
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
...
...
@@ -123,7 +124,7 @@ class DepGraphTestCase(support.LoggingCatcher,
def
test_dependent_dists_egg
(
self
):
dists
=
[]
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
:
dist
=
packaging
.
database
.
get_distribution
(
name
,
use_egg_info
=
True
)
dist
=
get_distribution
(
name
,
use_egg_info
=
True
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
...
...
@@ -158,12 +159,12 @@ class DepGraphTestCase(support.LoggingCatcher,
dists
=
[]
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
:
dist
=
packaging
.
database
.
get_distribution
(
name
,
use_egg_info
=
True
)
dist
=
get_distribution
(
name
,
use_egg_info
=
True
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
graph
=
depgraph
.
generate_graph
(
dists
)
buf
=
io
.
StringIO
()
buf
=
StringIO
()
depgraph
.
graph_to_dot
(
graph
,
buf
)
buf
.
seek
(
0
)
matches
=
[]
...
...
@@ -189,12 +190,12 @@ class DepGraphTestCase(support.LoggingCatcher,
dists
=
[]
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
:
dist
=
packaging
.
database
.
get_distribution
(
name
,
use_egg_info
=
True
)
dist
=
get_distribution
(
name
,
use_egg_info
=
True
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
graph
=
depgraph
.
generate_graph
(
dists
)
buf
=
io
.
StringIO
()
buf
=
StringIO
()
depgraph
.
graph_to_dot
(
graph
,
buf
,
skip_disconnected
=
False
)
buf
.
seek
(
0
)
lines
=
buf
.
readlines
()
...
...
@@ -250,12 +251,12 @@ class DepGraphTestCase(support.LoggingCatcher,
dists
=
[]
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
+
self
.
BAD_EGGS
:
dist
=
packaging
.
database
.
get_distribution
(
name
,
use_egg_info
=
True
)
dist
=
get_distribution
(
name
,
use_egg_info
=
True
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
graph
=
depgraph
.
generate_graph
(
dists
)
buf
=
io
.
StringIO
()
buf
=
StringIO
()
depgraph
.
graph_to_dot
(
graph
,
buf
)
buf
.
seek
(
0
)
matches
=
[]
...
...
@@ -273,7 +274,7 @@ class DepGraphTestCase(support.LoggingCatcher,
def
test_repr
(
self
):
dists
=
[]
for
name
in
self
.
DISTROS_DIST
+
self
.
DISTROS_EGG
+
self
.
BAD_EGGS
:
dist
=
packaging
.
database
.
get_distribution
(
name
,
use_egg_info
=
True
)
dist
=
get_distribution
(
name
,
use_egg_info
=
True
)
self
.
assertNotEqual
(
dist
,
None
)
dists
.
append
(
dist
)
...
...
@@ -282,7 +283,7 @@ class DepGraphTestCase(support.LoggingCatcher,
@requires_zlib
def
test_main
(
self
):
tempout
=
io
.
StringIO
()
tempout
=
StringIO
()
old
=
sys
.
stdout
sys
.
stdout
=
tempout
oldargv
=
sys
.
argv
[:]
...
...
Lib/packaging/tests/test_dist.py
Dosyayı görüntüle @
229011d9
...
...
@@ -3,13 +3,14 @@ import os
import
sys
import
logging
import
textwrap
import
packaging.dist
from
packaging.dist
import
Distribution
from
packaging.command
import
set_command
from
packaging.command.cmd
import
Command
from
packaging.errors
import
PackagingModuleError
,
PackagingOptionError
from
packaging.tests
import
TESTFN
,
captured_stdout
from
packaging.tests
import
captured_stdout
from
packaging.tests
import
support
,
unittest
from
packaging.tests.support
import
create_distribution
from
test.support
import
unload
...
...
@@ -48,12 +49,13 @@ class DistributionTestCase(support.TempdirManager,
@unittest.skip
(
'needs to be updated'
)
def
test_debug_mode
(
self
):
self
.
addCleanup
(
os
.
unlink
,
TESTFN
)
with
open
(
TESTFN
,
"w"
)
as
f
:
tmpdir
=
self
.
mkdtemp
()
setupcfg
=
os
.
path
.
join
(
tmpdir
,
'setup.cfg'
)
with
open
(
setupcfg
,
"w"
)
as
f
:
f
.
write
(
"[global]
\n
"
)
f
.
write
(
"command_packages = foo.bar, splat"
)
files
=
[
TESTFN
]
files
=
[
setupcfg
]
sys
.
argv
.
append
(
"build"
)
__
,
stdout
=
captured_stdout
(
create_distribution
,
files
)
self
.
assertEqual
(
stdout
,
''
)
...
...
Lib/packaging/tests/test_install.py
Dosyayı görüntüle @
229011d9
"""Tests for the packaging.install module."""
import
os
import
logging
from
sysconfig
import
is_python_build
from
tempfile
import
mkstemp
from
sysconfig
import
is_python_build
from
packaging
import
install
from
packaging.pypi.xmlrpc
import
Client
...
...
Lib/packaging/tests/test_pypi_server.py
Dosyayı görüntüle @
229011d9
"""Tests for packaging.command.bdist."""
import
sys
import
urllib.request
import
urllib.parse
import
urllib.error
try
:
import
threading
from
packaging.tests.pypi_server
import
PyPIServer
,
PYPI_DEFAULT_STATIC_PATH
from
packaging.tests.pypi_server
import
(
PyPIServer
,
PYPI_DEFAULT_STATIC_PATH
)
except
ImportError
:
threading
=
None
PyPIServer
=
None
...
...
@@ -32,18 +31,19 @@ class PyPIServerTest(unittest.TestCase):
headers
=
{
"X-test-header"
:
"Mister Iceberg"
}
request
=
urllib
.
request
.
Request
(
server
.
full_address
,
data
,
headers
)
request
=
urllib
.
request
.
Request
(
server
.
full_address
,
data
,
headers
)
urllib
.
request
.
urlopen
(
request
)
self
.
assertEqual
(
len
(
server
.
requests
),
1
)
handler
,
request_data
=
server
.
requests
[
-
1
]
self
.
assertIn
(
data
,
request_data
)
self
.
assertIn
(
"x-test-header"
,
handler
.
headers
)
self
.
assertEqual
(
handler
.
headers
[
"x-test-header"
],
"Mister Iceberg"
)
self
.
assertEqual
(
handler
.
headers
[
"x-test-header"
],
"Mister Iceberg"
)
finally
:
server
.
stop
()
def
test_serve_static_content
(
self
):
# PYPI Mocked server can serve static content from disk.
...
...
@@ -74,7 +74,8 @@ class PyPIServerTest(unittest.TestCase):
self
.
assertTrue
(
uses_local_files_for
(
server
,
"/simple/index.html"
))
# and another one in another root path
self
.
assertTrue
(
uses_local_files_for
(
server
,
"/external/index.html"
))
self
.
assertTrue
(
uses_local_files_for
(
server
,
"/external/index.html"
))
finally
:
server
.
stop
()
...
...
Lib/packaging/tests/test_run.py
Dosyayı görüntüle @
229011d9
...
...
@@ -2,11 +2,10 @@
import
os
import
sys
import
shutil
from
io
import
StringIO
from
packaging
import
install
from
packaging.tests
import
unittest
,
support
,
TESTFN
from
packaging.tests
import
unittest
,
support
from
packaging.run
import
main
from
test.script_helper
import
assert_python_ok
...
...
@@ -35,28 +34,14 @@ class RunTestCase(support.TempdirManager,
def
setUp
(
self
):
super
(
RunTestCase
,
self
)
.
setUp
()
self
.
old_stdout
=
sys
.
stdout
self
.
cleanup_testfn
()
self
.
old_argv
=
sys
.
argv
,
sys
.
argv
[:]
def
tearDown
(
self
):
sys
.
stdout
=
self
.
old_stdout
self
.
cleanup_testfn
()
sys
.
argv
=
self
.
old_argv
[
0
]
sys
.
argv
[:]
=
self
.
old_argv
[
1
]
super
(
RunTestCase
,
self
)
.
tearDown
()
def
cleanup_testfn
(
self
):
path
=
TESTFN
if
os
.
path
.
isfile
(
path
):
os
.
remove
(
path
)
elif
os
.
path
.
isdir
(
path
):
shutil
.
rmtree
(
path
)
def
write_setup
(
self
,
text
,
path
=
TESTFN
):
with
open
(
path
,
"w"
)
as
fp
:
fp
.
write
(
text
)
return
path
# TODO restore the tests removed six months ago and port them to pysetup
def
test_install
(
self
):
...
...
Lib/packaging/tests/test_util.py
Dosyayı görüntüle @
229011d9
...
...
@@ -15,7 +15,7 @@ from packaging.errors import (
from
packaging
import
util
from
packaging.dist
import
Distribution
from
packaging.util
import
(
convert_path
,
change_root
,
split_quoted
,
strtobool
,
convert_path
,
change_root
,
split_quoted
,
strtobool
,
run_2to3
,
get_compiler_versions
,
_MAC_OS_X_LD_VERSION
,
byte_compile
,
find_packages
,
spawn
,
get_pypirc_path
,
generate_pypirc
,
read_pypirc
,
resolve_name
,
iglob
,
RICH_GLOB
,
egginfo_to_distinfo
,
is_setuptools
,
is_distutils
,
is_packaging
,
...
...
@@ -374,7 +374,7 @@ class UtilTestCase(support.EnvironRestorer,
res
=
find_packages
([
root
],
[
'pkg1.pkg2'
])
self
.
assertEqual
(
set
(
res
),
set
([
'pkg1'
,
'pkg5'
,
'pkg1.pkg3'
,
'pkg1.pkg3.pkg6'
]))
'pkg1.pkg3.pkg6'
]))
def
test_resolve_name
(
self
):
self
.
assertIs
(
str
,
resolve_name
(
'builtins.str'
))
...
...
@@ -416,7 +416,6 @@ class UtilTestCase(support.EnvironRestorer,
file_handle
.
write
(
content
)
file_handle
.
flush
()
file_handle
.
seek
(
0
)
from
packaging.util
import
run_2to3
run_2to3
([
file_name
])
new_content
=
""
.
join
(
file_handle
.
read
())
file_handle
.
close
()
...
...
@@ -432,7 +431,6 @@ class UtilTestCase(support.EnvironRestorer,
file_handle
.
write
(
content
)
file_handle
.
flush
()
file_handle
.
seek
(
0
)
from
packaging.util
import
run_2to3
run_2to3
([
file_name
],
doctests_only
=
True
)
new_content
=
""
.
join
(
file_handle
.
readlines
())
file_handle
.
close
()
...
...
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