pypa / setuptools

Official project repository for the Setuptools build system
https://pypi.org/project/setuptools/
MIT License
2.5k stars 1.19k forks source link

[BUG] 65.6.2: move setuptools/tests to tests to fix pytest "as installed" #3711

Open kloczek opened 1 year ago

kloczek commented 1 year ago

setuptools version

65.6.2

Python version

3.8.15

OS

Linux x86/64

Additional environment information

N/A

Description

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

There are two issues:

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/bin/pytest", line 8, in sys.exit(console_main()) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 190, in console_main code = main() File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 148, in main config = _prepareconfig(args, plugins) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 329, in _prepareconfig config = pluginmanager.hook.pytest_cmdline_parse( File "/usr/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in call return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) File "/usr/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/usr/lib/python3.8/site-packages/pluggy/_callers.py", line 55, in _multicall gen.send(outcome) File "/usr/lib/python3.8/site-packages/_pytest/helpconfig.py", line 103, in pytest_cmdline_parse config: Config = outcome.get_result() File "/usr/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result raise ex[1].with_traceback(ex[2]) File "/usr/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall res = hook_impl.function(args) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 1058, in pytest_cmdline_parse self.parse(args) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 1346, in parse self._preparse(args, addopts=addopts) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 1248, in _preparse self.hook.pytest_load_initial_conftests( File "/usr/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in call return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult) File "/usr/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec return self._inner_hookexec(hook_name, methods, kwargs, firstresult) File "/usr/lib/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall return outcome.get_result() File "/usr/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result raise ex[1].with_traceback(ex[2]) File "/usr/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall res = hook_impl.function(args) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 1125, in pytest_load_initial_conftests self.pluginmanager._set_initial_conftests( File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 560, in _set_initial_conftests self._try_load_conftest(current, namespace.importmode, rootpath) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 574, in _try_load_conftest self._getconftestmodules(anchor, importmode, rootpath) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 603, in _getconftestmodules mod = self._importconftest(conftestpath, importmode, rootpath) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 651, in _importconftest self.consider_conftest(mod) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 732, in consider_conftest self.register(conftestmodule, name=conftestmodule.file) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 496, in register self.consider_module(plugin) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 740, in consider_module self._import_plugin_specs(getattr(mod, "pytest_plugins", [])) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 747, in _import_plugin_specs self.import_plugin(import_spec) File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 776, in import_plugin raise ImportError( File "/usr/lib/python3.8/site-packages/_pytest/config/init.py", line 774, in import_plugin import(importspec) ImportError: Error importing plugin "setuptools.tests.fixtures": No module named 'setuptools.tests

- second id that content of the setuptools/tests is included in generated .whl archive

pep517 automatically skipps tests/ content so after move setuptools/tests/ to tests second issue is automatically solved.

To be able use pytest after move setuptools/tests to testss/ needs to be added patch as well
```patch
--- a/conftest.py
+++ b/conftest.py
@@ -3,7 +3,7 @@
 import pytest

-pytest_plugins = 'setuptools.tests.fixtures'
+pytest_plugins = 'tests.fixtures'

 def pytest_addoption(parser):
--- a/setuptools/tests/test_setuptools.py
+++ b/setuptools/tests/test_setuptools.py
@@ -74,7 +74,7 @@
             dep.find_module('no-such.-thing')
         with pytest.raises(ImportError):
             dep.find_module('setuptools.non-existent')
-        f, p, i = dep.find_module('setuptools.tests')
+        f, p, i = dep.find_module('tests')
         f.close()

     @needs_bytecode
@@ -83,7 +83,7 @@
         assert dep.get_module_constant('json', '__version__') == __version__
         assert dep.get_module_constant('sys', 'version') == sys.version
         assert dep.get_module_constant(
-            'setuptools.tests.test_setuptools', '__doc__') == __doc__
+            'tests.test_setuptools', '__doc__') == __doc__

     @needs_bytecode
     def testRequire(self):
@@ -120,7 +120,7 @@
         assert req.full_name() == 'Tests'
         assert req.homepage == 'http://example.com'

-        from setuptools.tests import __path__
+        from tests import __path__
         paths = [os.path.dirname(p) for p in __path__]
         assert req.is_present(paths)
         assert req.is_current(paths)
--- a/setuptools/tests/test_sdist.py
+++ b/setuptools/tests/test_sdist.py
@@ -16,8 +16,8 @@
 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
+from tests import fail_on_ascii
+from tests.text import Filenames

 SETUP_ATTRS = {
--- a/setuptools/tests/test_manifest.py
+++ b/setuptools/tests/test_manifest.py
@@ -13,7 +13,7 @@

 from setuptools.command.egg_info import FileList, egg_info, translate_pattern
 from setuptools.dist import Distribution
-from setuptools.tests.textwrap import DALS
+from tests.textwrap import DALS

 import pytest

--- a/setuptools/tests/test_easy_install.py
+++ b/setuptools/tests/test_easy_install.py
@@ -34,8 +34,8 @@
 from setuptools.dist import Distribution
 from pkg_resources import normalize_path, working_set
 from pkg_resources import Distribution as PRDistribution
-from setuptools.tests.server import MockServer, path_to_url
-from setuptools.tests import fail_on_ascii
+from tests.server import MockServer, path_to_url
+from tests import fail_on_ascii
 import pkg_resources

 from . import contexts
--- a/setuptools/tests/test_depends.py
+++ b/setuptools/tests/test_depends.py
@@ -10,7 +10,7 @@
         Invoke get_module_constant on a module in
         the test package.
         """
-        mod_name = 'setuptools.tests.mod_with_constant'
+        mod_name = 'tests.mod_with_constant'
         val = depends.get_module_constant(mod_name, 'value')
         assert val == 'three, sir!'
-        assert 'setuptools.tests.mod_with_constant' not in sys.modules
+        assert 'tests.mod_with_constant' not in sys.modules
--- a/setuptools/tests/server.py
+++ b/setuptools/tests/server.py
@@ -17,7 +17,7 @@
         s.start()
         index_url = s.base_url() + 'mytestindex'
         # do some test requests to the index
-        # The index files should be located in setuptools/tests/indexes
+        # The index files should be located in tests/indexes
         s.stop()
     """

@@ -44,7 +44,7 @@

     def base_url(self):
         port = self.server_port
-        return 'http://127.0.0.1:%s/setuptools/tests/indexes/' % port
+        return 'http://127.0.0.1:%s/tests/indexes/' % port

 class RequestRecorder(http.server.BaseHTTPRequestHandler):
--- a/setuptools/tests/config/test_pyprojecttoml_dynamic_deps.py
+++ b/setuptools/tests/config/test_pyprojecttoml_dynamic_deps.py
@@ -2,7 +2,7 @@

 from setuptools.config.pyprojecttoml import apply_configuration
 from setuptools.dist import Distribution
-from setuptools.tests.textwrap import DALS
+from tests.textwrap import DALS

 def test_dynamic_dependencies(tmp_path):

Probably this is not all because tox needs to be adjusted as well.

Expected behavior

It should be possible to test setuptools using pytest.

How to Reproduce

N/A

Output

With moved test suite to tests/ and applied patch pytest was able to execute units.

kloczek commented 1 year ago

Here is reult of the pytests with above modyfications

```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages + /usr/bin/pytest -ra -p no:randomly tests =========================================================================== test session starts ============================================================================ platform linux -- Python 3.8.15, pytest-7.2.0, pluggy-1.0.0 rootdir: /home/tkloczko/rpmbuild/BUILD/setuptools-65.6.2, configfile: pytest.ini plugins: shutil-1.7.0, virtualenv-1.7.0, cov-4.0.0, flake8-1.1.1, xdist-3.0.2, checkdocs-2.9.0, timeout-2.1.0 collected 982 items tests/test_archive_util.py X [ 0%] tests/test_bdist_deprecations.py F [ 0%] tests/test_bdist_egg.py .x [ 0%] tests/test_build.py .. [ 0%] tests/test_build_clib.py .. [ 0%] tests/test_build_ext.py ........ [ 1%] tests/test_build_meta.py ........................................................................................................................................... [ 15%] ............................................................ [ 21%] tests/test_build_py.py ....x.. [ 22%] tests/test_config_discovery.py ................................................................................... [ 31%] tests/test_dep_util.py . [ 31%] tests/test_depends.py F [ 31%] tests/test_develop.py s.... [ 31%] tests/test_dist.py F......x...x............................................. [ 37%] tests/test_dist_info.py ...................................... [ 41%] tests/test_distutils_adoption.py ............. [ 42%] tests/test_easy_install.py .F...FFF......FF.F...FFFFFFFFFFFFFFFFFFFF..........F [ 48%] tests/test_editable_install.py ...............FF....................... [ 52%] tests/test_egg_info.py .........................x................................................. [ 59%] tests/test_extern.py ... [ 60%] tests/test_find_packages.py ................... [ 62%] tests/test_find_py_modules.py ......... [ 62%] tests/test_glob.py .... [ 63%] tests/test_install_scripts.py .s.s [ 63%] tests/test_integration.py sssss [ 64%] tests/test_logging.py .. [ 64%] tests/test_manifest.py ................................................................... [ 71%] tests/test_msvc14.py ssss [ 71%] tests/test_namespaces.py .... [ 72%] tests/test_packageindex.py ..................... [ 74%] tests/test_register.py . [ 74%] tests/test_sandbox.py .......... [ 75%] tests/test_sdist.py .................. [ 77%] tests/test_setopt.py .. [ 77%] tests/test_setuptools.py ....................... [ 79%] tests/test_test.py . [ 79%] tests/test_unicode_utils.py . [ 79%] tests/test_upload.py . [ 80%] tests/test_virtualenv.py ..x...X.. [ 80%] tests/test_wheel.py ........................ [ 83%] tests/test_windows_wrappers.py sss [ 83%] tests/config/test_apply_pyprojecttoml.py ..........................x..........F. [ 87%] tests/config/test_expand.py ....................... [ 90%] tests/config/test_pyprojecttoml.py ....................... [ 92%] tests/config/test_pyprojecttoml_dynamic_deps.py ... [ 92%] tests/config/test_setupcfg.py ................................................................ [ 99%] tests/integration/test_pip_install_sdist.py ssssssss [100%] ================================================================================= FAILURES ================================================================================= __________________________________________________________________________ test_bdist_rpm_warning __________________________________________________________________________ distutils_cmd = , tmpdir_cwd = local('/home/tkloczko/rpmbuild/BUILD/setuptools-65.6.2') @pytest.mark.skipif(sys.platform == 'win32', reason='non-Windows only') @mock.patch('distutils.command.bdist_rpm.bdist_rpm') def test_bdist_rpm_warning(distutils_cmd, tmpdir_cwd): dist = Distribution( dict( script_name='setup.py', script_args=['bdist_rpm'], name='foo', py_modules=['hi'], ) ) > dist.parse_command_line() /home/tkloczko/rpmbuild/BUILD/setuptools-65.6.2/tests/test_bdist_deprecations.py:23: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /home/tkloczko/rpmbuild/BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/_distutils/dist.py:475: in parse_command_line args = self._parse_command_opts(parser, args) /home/tkloczko/rpmbuild/BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/dist.py:1106: in _parse_command_opts nargs = _Distribution._parse_command_opts(self, parser, args) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , parser = , args = ['bdist_rpm'] def _parse_command_opts(self, parser, args): # noqa: C901 """Parse the command-line options for a single command. 'parser' must be a FancyGetopt instance; 'args' must be the list of arguments, starting with the current command (whose options we are about to parse). Returns a new version of 'args' with the next command at the front of the list; will be the empty list if there are no more commands on the command line. Returns None if the user asked for help on this command. """ # late import because of mutual dependence between these modules from distutils.cmd import Command # Pull the current command from the head of the command line command = args[0] if not command_re.match(command): raise SystemExit("invalid command name '%s'" % command) self.commands.append(command) # Dig up the command class that implements this command, so we # 1) know that it's a valid command, and 2) know which options # it takes. try: cmd_class = self.get_command_class(command) except DistutilsModuleError as msg: raise DistutilsArgError(msg) # Require that the command class be derived from Command -- want # to be sure that the basic "command" interface is implemented. > if not issubclass(cmd_class, Command): E TypeError: issubclass() arg 1 must be a class /home/tkloczko/rpmbuild/BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/_distutils/dist.py:540: TypeError _____________________________________________________________________ TestGetModuleConstant.test_basic _____________________________________________________________________ self = def test_basic(self): """ Invoke get_module_constant on a module in the test package. """ mod_name = 'tests.mod_with_constant' val = depends.get_module_constant(mod_name, 'value') assert val == 'three, sir!' > assert 'tests.mod_with_constant' not in sys.modules E AssertionError: assert 'tests.mod_with_constant' not in {'PIL': , 'PIL.Image': , 'PIL.TiffTags': , ...} E + where {'PIL': , 'PIL.Image': , 'PIL.TiffTags': , ...} = sys.modules tests/test_depends.py:16: AssertionError ________________________________________________________________________ test_dist_fetch_build_egg _________________________________________________________________________ v = '1.17.1-unknown' def parse_version(v): try: > return packaging.version.Version(v) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:121: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <[AttributeError("'Version' object has no attribute '_version'") raised in repr()] Version object at 0x7f5f1690f250>, version = '1.17.1-unknown' def __init__(self, version: str) -> None: # Validate the version and parse it into pieces match = self._regex.search(version) if not match: > raise InvalidVersion(f"Invalid version: '{version}'") E pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: '1.17.1-unknown' ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/version.py:266: InvalidVersion During handling of the above exception, another exception occurred: tmpdir = local('/tmp/pytest-of-tkloczko/pytest-429/test_dist_fetch_build_egg0') def test_dist_fetch_build_egg(tmpdir): """ Check multiple calls to `Distribution.fetch_build_egg` work as expected. """ index = tmpdir.mkdir('index') index_url = urllib.parse.urljoin( 'file://', urllib.request.pathname2url(str(index))) def sdist_with_index(distname, version): dist_dir = index.mkdir(distname) dist_sdist = '%s-%s.tar.gz' % (distname, version) make_nspkg_sdist(str(dist_dir.join(dist_sdist)), distname, version) with dist_dir.join('index.html').open('w') as fp: fp.write(DALS( ''' {dist_sdist}
''' ).format(dist_sdist=dist_sdist)) sdist_with_index('barbazquux', '3.2.0') sdist_with_index('barbazquux-runner', '2.11.1') with tmpdir.join('setup.cfg').open('w') as fp: fp.write(DALS( ''' [easy_install] index_url = {index_url} ''' ).format(index_url=index_url)) reqs = ''' barbazquux-runner barbazquux '''.split() with tmpdir.as_cwd(): dist = Distribution() dist.parse_config_files() > resolved_dists = [ dist.fetch_build_egg(r) for r in reqs ] tests/test_dist.py:63: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_dist.py:64: in dist.fetch_build_egg(r) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/dist.py:944: in fetch_build_egg return fetch_build_egg(self, req) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/installer.py:60: in fetch_build_egg environment = pkg_resources.Environment() ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:994: in __init__ self.scan(search_path) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:1027: in scan self.add(dist) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:1047: in add dists.sort(key=operator.attrgetter('hashcmp'), reverse=True) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:2620: in hashcmp self.parsed_version, ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:2667: in parsed_version self._parsed_version = parse_version(self.version) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:128: in parse_version return packaging.version.LegacyVersion(v) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , version = '1.17.1-unknown' def __init__(self, version: str) -> None: self._version = str(version) self._key = _legacy_cmpkey(self._version) > warnings.warn( "Creating a LegacyVersion has been deprecated and will be " "removed in the next major release", DeprecationWarning, ) E DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/version.py:111: DeprecationWarning __________________________________________________________________ TestEasyInstallTest.test_no_find_links __________________________________________________________________ v = '1.17.1-unknown' def parse_version(v): try: > return packaging.version.Version(v) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:121: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <[AttributeError("'Version' object has no attribute '_version'") raised in repr()] Version object at 0x7f5f0e728460>, version = '1.17.1-unknown' def __init__(self, version: str) -> None: # Validate the version and parse it into pieces match = self._regex.search(version) if not match: > raise InvalidVersion(f"Invalid version: '{version}'") E pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: '1.17.1-unknown' ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/version.py:266: InvalidVersion During handling of the above exception, another exception occurred: self = def test_no_find_links(self): # new option '--no-find-links', that blocks find-links added at # the project level dist = Distribution() cmd = ei.easy_install(dist) cmd.check_pth_processing = lambda: True cmd.no_find_links = True cmd.find_links = ['link1', 'link2'] cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') cmd.args = ['ok'] > cmd.ensure_finalized() tests/test_easy_install.py:95: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/_distutils/cmd.py:111: in ensure_finalized self.finalize_options() ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/command/easy_install.py:311: in finalize_options self.local_index = Environment(self.shadow_path + sys.path) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:994: in __init__ self.scan(search_path) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:1027: in scan self.add(dist) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:1047: in add dists.sort(key=operator.attrgetter('hashcmp'), reverse=True) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:2620: in hashcmp self.parsed_version, ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:2667: in parsed_version self._parsed_version = parse_version(self.version) ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/__init__.py:128: in parse_version return packaging.version.LegacyVersion(v) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , version = '1.17.1-unknown' def __init__(self, version: str) -> None: self._version = str(version) self._key = _legacy_cmpkey(self._version) > warnings.warn( "Creating a LegacyVersion has been deprecated and will be " "removed in the next major release", DeprecationWarning, ) E DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release ../../BUILDROOT/python-setuptools-65.6.2-2.fc35.x86_64/usr/lib/python3.8/site-packages/pkg_resources/_vendor/packaging/version.py:111: DeprecationWarning [..] ========================================================================= short test summary info ========================================================================== SKIPPED [1] tests/test_develop.py:64: TODO: needs a fixture to cause 'develop' to be invoked without mutating environment. SKIPPED [1] tests/test_install_scripts.py:50: Windows only SKIPPED [1] tests/test_install_scripts.py:78: Windows only SKIPPED [5] tests/test_integration.py:31: Integration tests cannot run when pbr is installed SKIPPED [1] tests/test_msvc14.py:15: These tests are only for win32 SKIPPED [1] tests/test_msvc14.py:33: These tests are only for win32 SKIPPED [1] tests/test_msvc14.py:51: These tests are only for win32 SKIPPED [1] tests/test_msvc14.py:67: These tests are only for win32 SKIPPED [1] tests/test_windows_wrappers.py:80: Windows only SKIPPED [1] tests/test_windows_wrappers.py:121: Windows only SKIPPED [1] tests/test_windows_wrappers.py:182: Windows only SKIPPED [8] conftest.py:51: skipping integration tests XFAIL tests/test_bdist_egg.py::Test::test_exclude_source_files - Byte code disabled XFAIL tests/test_build_py.py::test_excluded_subpackages - reason: #3260 XFAIL tests/test_dist.py::test_read_metadata[Metadata Version 1.2: Project-Url-attrs5] - Issue #1578: project_urls not read XFAIL tests/test_dist.py::test_read_metadata[Metadata Version 2.1: Provides Extra-attrs9] - provides_extras not read XFAIL tests/test_egg_info.py::TestEggInfo::test_requires[extras_require_with_marker_in_setup_cfg] XFAIL tests/test_virtualenv.py::test_pip_upgrade_from_source[pip<20] - pypa/pip#6599 XFAIL tests/config/test_apply_pyprojecttoml.py::test_utf8_maintainer_in_metadata[international-email] - CPython's `email.headerregistry.Address` only supports RFC 5322, as of Nov 10, 2022 and latest Python 3.11.0 XPASS tests/test_archive_util.py::test_unicode_files #710 and #712 XPASS tests/test_virtualenv.py::test_pip_upgrade_from_source[https://github.com/pypa/pip/archive/main.zip] #2975 FAILED tests/test_bdist_deprecations.py::test_bdist_rpm_warning - TypeError: issubclass() arg 1 must be a class FAILED tests/test_depends.py::TestGetModuleConstant::test_basic - AssertionError: assert 'tests.mod_with_constant' not in {'PIL': , 'PIL.Image':

As you seee some units are failimng but ar least pytest was able to start. Here is full pytest log python-setuptools.txt

kloczek commented 1 year ago

Please let me know if you want above as PR and/or what more needs to be done ..

jaraco commented 1 year ago

Currently, the setuptools distribution has several packages, mainly setuptools and pkg_resources, but also _distutils_hack and other top-level names. In particular, the setuptools and pkg_resources packages have fairly strict separation (in particular, pkg_resources can't import setuptools), and that's why the tests are organized into each of the packages (setuptools/tests and pkg_resources/tests).

Until the project can remove reliance on pkg_resources, I'm uncomfortable with the idea of breaking the symmetry and having pkg_resources/tests but not setuptools/tests.

I'm a little worried too that the reason that you're encountering the error ModuleNotFoundError: No module named 'setuptools.tests' may be an indication that the module under test isn't in fact the one you're attempting to test. It's conceivable to me that the workaround you've devised is only masking a more serious issue, that you're testing another copy of setuptools as installed, which may not be the version from the source. Can you confirm that the module under test is in fact an installed copy that comes from the same source as the tests?

Additionally, do you know why it is that you don't encounter similar issues with pkg_resources/tests? Would you encounter similar issues with pkg_resources/tests if those tests started importing behaviors from other modules in that package?

kloczek commented 1 year ago

All what you wrote is OK, and I understand that however looks like move setuptools/tests/ to tests/ can be done without disturbing whole current state additionally bringing everything to the state when setuptools module would be testable using pytest.

Generally issue is that setuptools/tests content is not part of installeable resources dso this is why on testing unmodified tree is not possible to find setuptools.tests and pytest automatically scans tests/ content. Just please try test a bit what I've proposed because. I was unable to find easier method to bring everything to working state on testing using pytest 😋 If you see such method just please implemnent that 😄