Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
8e0ac920
Commit
8e0ac920
authored
Dec 01, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expect failure running Python 3 only tests on Python 2
parent
adcf0265
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
104 deletions
+107
-104
setuptools/tests/__init__.py
setuptools/tests/__init__.py
+1
-0
setuptools/tests/test_sdist.py
setuptools/tests/test_sdist.py
+106
-104
No files found.
setuptools/tests/__init__.py
View file @
8e0ac920
...
...
@@ -20,6 +20,7 @@ c_type = os.environ.get("LC_CTYPE", os.environ.get("LC_ALL"))
is_ascii
=
c_type
in
(
"C"
,
"POSIX"
)
fail_on_ascii
=
pytest
.
mark
.
xfail
(
is_ascii
,
reason
=
"Test fails in this locale"
)
def
makeSetup
(
**
args
):
"""Return distribution from 'setup(**args)', without executing commands"""
...
...
setuptools/tests/test_sdist.py
View file @
8e0ac920
...
...
@@ -8,6 +8,8 @@ import tempfile
import
unicodedata
import
contextlib
import
pytest
import
pkg_resources
from
setuptools.compat
import
StringIO
,
unicode
,
PY3
,
PY2
from
setuptools.command.sdist
import
sdist
...
...
@@ -16,6 +18,9 @@ from setuptools.dist import Distribution
from
setuptools.tests
import
fail_on_ascii
py3_only
=
pytest
.
mark
.
xfail
(
PY2
,
reason
=
"Test runs on Python 3 only"
)
SETUP_ATTRS
=
{
'name'
:
'sdist_test'
,
'version'
:
'0.0'
,
...
...
@@ -181,80 +186,79 @@ class TestSdistTest:
assert
posix
(
filename
)
in
u_contents
# Python 3 only
if
PY3
:
@
py3_only
def
test_write_manifest_allows_utf8_filenames
(
self
):
# Test for #303.
dist
=
Distribution
(
SETUP_ATTRS
)
dist
.
script_name
=
'setup.py'
mm
=
manifest_maker
(
dist
)
mm
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
os
.
mkdir
(
'sdist_test.egg-info'
)
def
test_write_manifest_allows_utf8_filenames
(
self
):
# Test for #303.
dist
=
Distribution
(
SETUP_ATTRS
)
dist
.
script_name
=
'setup.py'
mm
=
manifest_maker
(
dist
)
mm
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
os
.
mkdir
(
'sdist_test.egg-info'
)
# UTF-8 filename
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
b
(
'smörbröd.py'
))
# Must touch the file or risk removal
open
(
filename
,
"w"
).
close
()
# Add filename and write manifest
with
quiet
():
mm
.
run
()
u_filename
=
filename
.
decode
(
'utf-8'
)
mm
.
filelist
.
files
.
append
(
u_filename
)
# Re-write manifest
mm
.
write_manifest
()
manifest
=
open
(
mm
.
manifest
,
'rbU'
)
contents
=
manifest
.
read
()
manifest
.
close
()
# The manifest should be UTF-8 encoded
contents
.
decode
(
'UTF-8'
)
# The manifest should contain the UTF-8 filename
assert
posix
(
filename
)
in
contents
# The filelist should have been updated as well
assert
u_filename
in
mm
.
filelist
.
files
def
test_write_manifest_skips_non_utf8_filenames
(
self
):
"""
Files that cannot be encoded to UTF-8 (specifically, those that
weren't originally successfully decoded and have surrogate
escapes) should be omitted from the manifest.
See https://bitbucket.org/tarek/distribute/issue/303 for history.
"""
dist
=
Distribution
(
SETUP_ATTRS
)
dist
.
script_name
=
'setup.py'
mm
=
manifest_maker
(
dist
)
mm
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
os
.
mkdir
(
'sdist_test.egg-info'
)
# Latin-1 filename
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
LATIN1_FILENAME
)
# Add filename with surrogates and write manifest
with
quiet
():
mm
.
run
()
u_filename
=
filename
.
decode
(
'utf-8'
,
'surrogateescape'
)
mm
.
filelist
.
append
(
u_filename
)
# Re-write manifest
mm
.
write_manifest
()
manifest
=
open
(
mm
.
manifest
,
'rbU'
)
contents
=
manifest
.
read
()
manifest
.
close
()
# The manifest should be UTF-8 encoded
contents
.
decode
(
'UTF-8'
)
# The Latin-1 filename should have been skipped
assert
posix
(
filename
)
not
in
contents
# The filelist should have been updated as well
assert
u_filename
not
in
mm
.
filelist
.
files
# UTF-8 filename
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
b
(
'smörbröd.py'
))
# Must touch the file or risk removal
open
(
filename
,
"w"
).
close
()
# Add filename and write manifest
with
quiet
():
mm
.
run
()
u_filename
=
filename
.
decode
(
'utf-8'
)
mm
.
filelist
.
files
.
append
(
u_filename
)
# Re-write manifest
mm
.
write_manifest
()
manifest
=
open
(
mm
.
manifest
,
'rbU'
)
contents
=
manifest
.
read
()
manifest
.
close
()
# The manifest should be UTF-8 encoded
contents
.
decode
(
'UTF-8'
)
# The manifest should contain the UTF-8 filename
assert
posix
(
filename
)
in
contents
# The filelist should have been updated as well
assert
u_filename
in
mm
.
filelist
.
files
@
py3_only
def
test_write_manifest_skips_non_utf8_filenames
(
self
):
"""
Files that cannot be encoded to UTF-8 (specifically, those that
weren't originally successfully decoded and have surrogate
escapes) should be omitted from the manifest.
See https://bitbucket.org/tarek/distribute/issue/303 for history.
"""
dist
=
Distribution
(
SETUP_ATTRS
)
dist
.
script_name
=
'setup.py'
mm
=
manifest_maker
(
dist
)
mm
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
os
.
mkdir
(
'sdist_test.egg-info'
)
# Latin-1 filename
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
LATIN1_FILENAME
)
# Add filename with surrogates and write manifest
with
quiet
():
mm
.
run
()
u_filename
=
filename
.
decode
(
'utf-8'
,
'surrogateescape'
)
mm
.
filelist
.
append
(
u_filename
)
# Re-write manifest
mm
.
write_manifest
()
manifest
=
open
(
mm
.
manifest
,
'rbU'
)
contents
=
manifest
.
read
()
manifest
.
close
()
# The manifest should be UTF-8 encoded
contents
.
decode
(
'UTF-8'
)
# The Latin-1 filename should have been skipped
assert
posix
(
filename
)
not
in
contents
# The filelist should have been updated as well
assert
u_filename
not
in
mm
.
filelist
.
files
@
fail_on_ascii
def
test_manifest_is_read_with_utf8_encoding
(
self
):
...
...
@@ -288,38 +292,36 @@ class TestSdistTest:
filename
=
filename
.
decode
(
'utf-8'
)
assert
filename
in
cmd
.
filelist
.
files
# Python 3 only
if
PY3
:
@
py3_only
def
test_read_manifest_skips_non_utf8_filenames
(
self
):
# Test for #303.
dist
=
Distribution
(
SETUP_ATTRS
)
dist
.
script_name
=
'setup.py'
cmd
=
sdist
(
dist
)
cmd
.
ensure_finalized
()
# Create manifest
with
quiet
():
cmd
.
run
()
# Add Latin-1 filename to manifest
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
LATIN1_FILENAME
)
cmd
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
manifest
=
open
(
cmd
.
manifest
,
'ab'
)
manifest
.
write
(
b
(
'
\
n
'
)
+
filename
)
manifest
.
close
()
# The file must exist to be included in the filelist
open
(
filename
,
'w'
).
close
()
# Re-read manifest
cmd
.
filelist
.
files
=
[]
with
quiet
():
cmd
.
read_manifest
()
def
test_read_manifest_skips_non_utf8_filenames
(
self
):
# Test for #303.
dist
=
Distribution
(
SETUP_ATTRS
)
dist
.
script_name
=
'setup.py'
cmd
=
sdist
(
dist
)
cmd
.
ensure_finalized
()
# Create manifest
with
quiet
():
cmd
.
run
()
# Add Latin-1 filename to manifest
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
LATIN1_FILENAME
)
cmd
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
manifest
=
open
(
cmd
.
manifest
,
'ab'
)
manifest
.
write
(
b
(
'
\
n
'
)
+
filename
)
manifest
.
close
()
# The file must exist to be included in the filelist
open
(
filename
,
'w'
).
close
()
# Re-read manifest
cmd
.
filelist
.
files
=
[]
with
quiet
():
cmd
.
read_manifest
()
# The Latin-1 filename should have been skipped
filename
=
filename
.
decode
(
'latin-1'
)
assert
filename
not
in
cmd
.
filelist
.
files
# The Latin-1 filename should have been skipped
filename
=
filename
.
decode
(
'latin-1'
)
assert
filename
not
in
cmd
.
filelist
.
files
@
fail_on_ascii
def
test_sdist_with_utf8_encoded_filename
(
self
):
...
...
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