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"))
...
@@ -20,6 +20,7 @@ c_type = os.environ.get("LC_CTYPE", os.environ.get("LC_ALL"))
is_ascii
=
c_type
in
(
"C"
,
"POSIX"
)
is_ascii
=
c_type
in
(
"C"
,
"POSIX"
)
fail_on_ascii
=
pytest
.
mark
.
xfail
(
is_ascii
,
reason
=
"Test fails in this locale"
)
fail_on_ascii
=
pytest
.
mark
.
xfail
(
is_ascii
,
reason
=
"Test fails in this locale"
)
def
makeSetup
(
**
args
):
def
makeSetup
(
**
args
):
"""Return distribution from 'setup(**args)', without executing commands"""
"""Return distribution from 'setup(**args)', without executing commands"""
...
...
setuptools/tests/test_sdist.py
View file @
8e0ac920
...
@@ -8,6 +8,8 @@ import tempfile
...
@@ -8,6 +8,8 @@ import tempfile
import
unicodedata
import
unicodedata
import
contextlib
import
contextlib
import
pytest
import
pkg_resources
import
pkg_resources
from
setuptools.compat
import
StringIO
,
unicode
,
PY3
,
PY2
from
setuptools.compat
import
StringIO
,
unicode
,
PY3
,
PY2
from
setuptools.command.sdist
import
sdist
from
setuptools.command.sdist
import
sdist
...
@@ -16,6 +18,9 @@ from setuptools.dist import Distribution
...
@@ -16,6 +18,9 @@ from setuptools.dist import Distribution
from
setuptools.tests
import
fail_on_ascii
from
setuptools.tests
import
fail_on_ascii
py3_only
=
pytest
.
mark
.
xfail
(
PY2
,
reason
=
"Test runs on Python 3 only"
)
SETUP_ATTRS
=
{
SETUP_ATTRS
=
{
'name'
:
'sdist_test'
,
'name'
:
'sdist_test'
,
'version'
:
'0.0'
,
'version'
:
'0.0'
,
...
@@ -181,80 +186,79 @@ class TestSdistTest:
...
@@ -181,80 +186,79 @@ class TestSdistTest:
assert
posix
(
filename
)
in
u_contents
assert
posix
(
filename
)
in
u_contents
# Python 3 only
@
py3_only
if
PY3
:
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
):
# UTF-8 filename
# Test for #303.
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
b
(
'smörbröd.py'
))
dist
=
Distribution
(
SETUP_ATTRS
)
dist
.
script_name
=
'setup.py'
# Must touch the file or risk removal
mm
=
manifest_maker
(
dist
)
open
(
filename
,
"w"
).
close
()
mm
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
os
.
mkdir
(
'sdist_test.egg-info'
)
# Add filename and write manifest
with
quiet
():
# UTF-8 filename
mm
.
run
()
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
b
(
'smörbröd.py'
))
u_filename
=
filename
.
decode
(
'utf-8'
)
mm
.
filelist
.
files
.
append
(
u_filename
)
# Must touch the file or risk removal
# Re-write manifest
open
(
filename
,
"w"
).
close
()
mm
.
write_manifest
()
# Add filename and write manifest
manifest
=
open
(
mm
.
manifest
,
'rbU'
)
with
quiet
():
contents
=
manifest
.
read
()
mm
.
run
()
manifest
.
close
()
u_filename
=
filename
.
decode
(
'utf-8'
)
mm
.
filelist
.
files
.
append
(
u_filename
)
# The manifest should be UTF-8 encoded
# Re-write manifest
contents
.
decode
(
'UTF-8'
)
mm
.
write_manifest
()
# The manifest should contain the UTF-8 filename
manifest
=
open
(
mm
.
manifest
,
'rbU'
)
assert
posix
(
filename
)
in
contents
contents
=
manifest
.
read
()
manifest
.
close
()
# The filelist should have been updated as well
assert
u_filename
in
mm
.
filelist
.
files
# The manifest should be UTF-8 encoded
contents
.
decode
(
'UTF-8'
)
@
py3_only
def
test_write_manifest_skips_non_utf8_filenames
(
self
):
# The manifest should contain the UTF-8 filename
"""
assert
posix
(
filename
)
in
contents
Files that cannot be encoded to UTF-8 (specifically, those that
weren't originally successfully decoded and have surrogate
# The filelist should have been updated as well
escapes) should be omitted from the manifest.
assert
u_filename
in
mm
.
filelist
.
files
See https://bitbucket.org/tarek/distribute/issue/303 for history.
"""
def
test_write_manifest_skips_non_utf8_filenames
(
self
):
dist
=
Distribution
(
SETUP_ATTRS
)
"""
dist
.
script_name
=
'setup.py'
Files that cannot be encoded to UTF-8 (specifically, those that
mm
=
manifest_maker
(
dist
)
weren't originally successfully decoded and have surrogate
mm
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
escapes) should be omitted from the manifest.
os
.
mkdir
(
'sdist_test.egg-info'
)
See https://bitbucket.org/tarek/distribute/issue/303 for history.
"""
# Latin-1 filename
dist
=
Distribution
(
SETUP_ATTRS
)
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
LATIN1_FILENAME
)
dist
.
script_name
=
'setup.py'
mm
=
manifest_maker
(
dist
)
# Add filename with surrogates and write manifest
mm
.
manifest
=
os
.
path
.
join
(
'sdist_test.egg-info'
,
'SOURCES.txt'
)
with
quiet
():
os
.
mkdir
(
'sdist_test.egg-info'
)
mm
.
run
()
u_filename
=
filename
.
decode
(
'utf-8'
,
'surrogateescape'
)
# Latin-1 filename
mm
.
filelist
.
append
(
u_filename
)
filename
=
os
.
path
.
join
(
b
(
'sdist_test'
),
LATIN1_FILENAME
)
# Re-write manifest
mm
.
write_manifest
()
# Add filename with surrogates and write manifest
with
quiet
():
manifest
=
open
(
mm
.
manifest
,
'rbU'
)
mm
.
run
()
contents
=
manifest
.
read
()
u_filename
=
filename
.
decode
(
'utf-8'
,
'surrogateescape'
)
manifest
.
close
()
mm
.
filelist
.
append
(
u_filename
)
# Re-write manifest
# The manifest should be UTF-8 encoded
mm
.
write_manifest
()
contents
.
decode
(
'UTF-8'
)
manifest
=
open
(
mm
.
manifest
,
'rbU'
)
# The Latin-1 filename should have been skipped
contents
=
manifest
.
read
()
assert
posix
(
filename
)
not
in
contents
manifest
.
close
()
# The filelist should have been updated as well
# The manifest should be UTF-8 encoded
assert
u_filename
not
in
mm
.
filelist
.
files
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
@
fail_on_ascii
def
test_manifest_is_read_with_utf8_encoding
(
self
):
def
test_manifest_is_read_with_utf8_encoding
(
self
):
...
@@ -288,38 +292,36 @@ class TestSdistTest:
...
@@ -288,38 +292,36 @@ class TestSdistTest:
filename
=
filename
.
decode
(
'utf-8'
)
filename
=
filename
.
decode
(
'utf-8'
)
assert
filename
in
cmd
.
filelist
.
files
assert
filename
in
cmd
.
filelist
.
files
# Python 3 only
@
py3_only
if
PY3
:
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
):
# The Latin-1 filename should have been skipped
# Test for #303.
filename
=
filename
.
decode
(
'latin-1'
)
dist
=
Distribution
(
SETUP_ATTRS
)
assert
filename
not
in
cmd
.
filelist
.
files
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
@
fail_on_ascii
@
fail_on_ascii
def
test_sdist_with_utf8_encoded_filename
(
self
):
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