Commit ba46991d authored by Jason R. Coombs's avatar Jason R. Coombs

Move filename fixtures to a 'text' module so they can use unicode literals.

parent a85c59d3
......@@ -19,6 +19,7 @@ from setuptools.command.sdist import sdist
from setuptools.command.egg_info import manifest_maker
from setuptools.dist import Distribution
from setuptools.tests import fail_on_ascii
from .text import Filenames
py3_only = pytest.mark.xfail(six.PY2, reason="Test runs on Python 3 only")
......@@ -36,13 +37,6 @@ from setuptools import setup
setup(**%r)
""" % SETUP_ATTRS
if six.PY3:
LATIN1_FILENAME = 'smörbröd.py'.encode('latin-1')
else:
LATIN1_FILENAME = 'sm\xf6rbr\xf6d.py'
utf_8_filename = LATIN1_FILENAME.decode('latin-1').encode('utf-8')
@contextlib.contextmanager
def quiet():
......@@ -82,7 +76,7 @@ def read_all_bytes(filename):
def latin1_fail():
try:
desc, filename = tempfile.mkstemp(suffix=LATIN1_FILENAME)
desc, filename = tempfile.mkstemp(suffix=Filenames.latin_1)
os.close(desc)
os.remove(filename)
except Exception:
......@@ -212,7 +206,7 @@ class TestSdistTest:
mm.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
os.mkdir('sdist_test.egg-info')
filename = os.path.join(b'sdist_test', utf_8_filename)
filename = os.path.join(b'sdist_test', Filenames.utf_8)
# Must touch the file or risk removal
open(filename, "w").close()
......@@ -251,7 +245,7 @@ class TestSdistTest:
os.mkdir('sdist_test.egg-info')
# Latin-1 filename
filename = os.path.join(b'sdist_test', LATIN1_FILENAME)
filename = os.path.join(b'sdist_test', Filenames.latin_1)
# Add filename with surrogates and write manifest
with quiet():
......@@ -285,7 +279,7 @@ class TestSdistTest:
cmd.run()
# Add UTF-8 filename to manifest
filename = os.path.join(b'sdist_test', utf_8_filename)
filename = os.path.join(b'sdist_test', Filenames.utf_8)
cmd.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
manifest = open(cmd.manifest, 'ab')
manifest.write(b'\n' + filename)
......@@ -318,7 +312,7 @@ class TestSdistTest:
cmd.run()
# Add Latin-1 filename to manifest
filename = os.path.join(b'sdist_test', LATIN1_FILENAME)
filename = os.path.join(b'sdist_test', Filenames.latin_1)
cmd.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
manifest = open(cmd.manifest, 'ab')
manifest.write(b'\n' + filename)
......@@ -345,8 +339,7 @@ class TestSdistTest:
cmd = sdist(dist)
cmd.ensure_finalized()
# UTF-8 filename
filename = os.path.join(b'sdist_test', utf_8_filename)
filename = os.path.join(b'sdist_test', Filenames.utf_8)
open(filename, 'w').close()
with quiet():
......@@ -381,7 +374,7 @@ class TestSdistTest:
cmd.ensure_finalized()
# Latin-1 filename
filename = os.path.join(b'sdist_test', LATIN1_FILENAME)
filename = os.path.join(b'sdist_test', Filenames.latin_1)
open(filename, 'w').close()
assert os.path.isfile(filename)
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
class Filenames:
unicode = 'smörbröd.py'
latin_1 = unicode.encode('latin-1')
utf_8 = unicode.encode('utf-8')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment