summaryrefslogtreecommitdiff
path: root/setuptools/tests
diff options
context:
space:
mode:
Diffstat (limited to 'setuptools/tests')
-rw-r--r--setuptools/tests/fixtures.py16
-rw-r--r--setuptools/tests/test_easy_install.py53
-rw-r--r--setuptools/tests/test_msvc.py4
3 files changed, 63 insertions, 10 deletions
diff --git a/setuptools/tests/fixtures.py b/setuptools/tests/fixtures.py
index c70c38cb..5204c8d1 100644
--- a/setuptools/tests/fixtures.py
+++ b/setuptools/tests/fixtures.py
@@ -1,24 +1,20 @@
-try:
- from unittest import mock
-except ImportError:
- import mock
import pytest
from . import contexts
@pytest.yield_fixture
-def user_override():
+def user_override(monkeypatch):
"""
Override site.USER_BASE and site.USER_SITE with temporary directories in
a context.
"""
with contexts.tempdir() as user_base:
- with mock.patch('site.USER_BASE', user_base):
- with contexts.tempdir() as user_site:
- with mock.patch('site.USER_SITE', user_site):
- with contexts.save_user_site_setting():
- yield
+ monkeypatch.setattr('site.USER_BASE', user_base)
+ with contexts.tempdir() as user_site:
+ monkeypatch.setattr('site.USER_SITE', user_site)
+ with contexts.save_user_site_setting():
+ yield
@pytest.yield_fixture
diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py
index 11299c7c..b2094901 100644
--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -14,6 +14,7 @@ import logging
import itertools
import distutils.errors
import io
+import zipfile
import time
from setuptools.extern.six.moves import urllib
@@ -135,6 +136,58 @@ class TestEasyInstallTest:
monkeypatch.delattr(site, 'getsitepackages', raising=False)
assert ei.get_site_dirs()
+ @pytest.fixture
+ def sdist_unicode(self, tmpdir):
+ files = [
+ (
+ 'setup.py',
+ DALS("""
+ import setuptools
+ setuptools.setup(
+ name="setuptools-test-unicode",
+ version="1.0",
+ packages=["mypkg"],
+ include_package_data=True,
+ )
+ """),
+ ),
+ (
+ 'mypkg/__init__.py',
+ "",
+ ),
+ (
+ u'mypkg/\u2603.txt',
+ "",
+ ),
+ ]
+ sdist_name = 'setuptools-test-unicode-1.0.zip'
+ sdist = tmpdir / sdist_name
+ # can't use make_sdist, because the issue only occurs
+ # with zip sdists.
+ sdist_zip = zipfile.ZipFile(str(sdist), 'w')
+ for filename, content in files:
+ sdist_zip.writestr(filename, content)
+ sdist_zip.close()
+ return str(sdist)
+
+ @pytest.mark.xfail(setuptools.tests.is_ascii,
+ reason="https://github.com/pypa/setuptools/issues/706")
+ def test_unicode_filename_in_sdist(self, sdist_unicode, tmpdir, monkeypatch):
+ """
+ The install command should execute correctly even if
+ the package has unicode filenames.
+ """
+ dist = Distribution({'script_args': ['easy_install']})
+ target = (tmpdir / 'target').ensure_dir()
+ cmd = ei.easy_install(
+ dist,
+ install_dir=str(target),
+ args=['x'],
+ )
+ monkeypatch.setitem(os.environ, 'PYTHONPATH', str(target))
+ cmd.ensure_finalized()
+ cmd.easy_install(sdist_unicode)
+
class TestPTHFileWriter:
diff --git a/setuptools/tests/test_msvc.py b/setuptools/tests/test_msvc.py
index a0c76ea0..8c7e17d3 100644
--- a/setuptools/tests/test_msvc.py
+++ b/setuptools/tests/test_msvc.py
@@ -6,6 +6,8 @@ import os
import contextlib
import distutils.errors
+from setuptools.extern import six
+
import pytest
try:
from unittest import mock
@@ -71,6 +73,8 @@ class TestModulePatch:
mod_name = distutils.msvc9compiler.find_vcvarsall.__module__
assert mod_name == "setuptools.msvc", "find_vcvarsall unpatched"
+ @pytest.mark.xfail(six.PY2,
+ reason="https://github.com/pypa/setuptools/issues/707")
def test_no_registry_entries_means_nothing_found(self):
"""
No registry entries or environment variable should lead to an error