Open kloczek opened 1 year ago
Here is reult of the pytests with above modyfications
As you seee some units are failimng but ar least pytest was able to start. Here is full pytest log python-setuptools.txt
Please let me know if you want above as PR and/or what more needs to be done ..
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?
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 😄
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.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulesThere 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
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.