diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py index 54dd7d2b20..5f4a1c2958 100644 --- a/setuptools/tests/__init__.py +++ b/setuptools/tests/__init__.py @@ -2,5 +2,17 @@ import pytest +from setuptools.extern.six import PY2, PY3 + + +__all__ = [ + 'fail_on_ascii', 'py2_only', 'py3_only' +] + + is_ascii = locale.getpreferredencoding() == 'ANSI_X3.4-1968' fail_on_ascii = pytest.mark.xfail(is_ascii, reason="Test fails in this locale") + + +py2_only = pytest.mark.skipif(not PY2, reason="Test runs on Python 2 only") +py3_only = pytest.mark.skipif(not PY3, reason="Test runs on Python 3 only") diff --git a/setuptools/tests/test_config.py b/setuptools/tests/test_config.py index 23e14796df..9a4c83906b 100644 --- a/setuptools/tests/test_config.py +++ b/setuptools/tests/test_config.py @@ -4,10 +4,7 @@ from mock import patch from setuptools.dist import Distribution, _Distribution from setuptools.config import ConfigHandler, read_configuration -from setuptools.extern.six import PY2, PY3 - -py2_only = pytest.mark.skipif(not PY2, reason="Test runs on Python 2 only") -py3_only = pytest.mark.skipif(not PY3, reason="Test runs on Python 3 only") +from setuptools.tests import py2_only, py3_only class ErrConfigHandler(ConfigHandler): """Erroneous handler. Fails to implement required methods.""" @@ -610,8 +607,8 @@ def test_find_namespace_directive_fails_on_py2(self, tmpdir): ) with pytest.raises(DistutilsOptionError): - with get_dist(tmpdir) as dist: - dist.parse_config_files() + with get_dist(tmpdir) as dist: + dist.parse_config_files() @py3_only def test_find_namespace_directive(self, tmpdir): diff --git a/setuptools/tests/test_find_packages.py b/setuptools/tests/test_find_packages.py index 02ae5a946d..f6e75053a7 100644 --- a/setuptools/tests/test_find_packages.py +++ b/setuptools/tests/test_find_packages.py @@ -7,10 +7,10 @@ import pytest +from setuptools.tests import py3_only + from setuptools.extern.six import PY3 from setuptools import find_packages - -py3_only = pytest.mark.xfail(not PY3, reason="Test runs on Python 3 only") if PY3: from setuptools import find_packages_ns