[BUG] 60.1.0: pytest fails on collecting Windows specific units on Linux
See original GitHub issuesetuptools version
60.1.0
Python version
3.8.12
OS
Linux/x86_64
Additional environment information
No response
Description
Looks like pytest is failing on collecting phase on _distutils/
units which are Windows specyfic.
I thinlk tjat tjey should be marked to skip on non-Windows systems.
Expected behavior
Windows specific units should be collected only when pytest is executes in Windows build env.
How to Reproduce
Just run pytest in non-Windows build env.
Output
+ pytest -ra -p no:randomly --pyargs setuptools.tests setuptools
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/setuptools-60.1.0, configfile: pytest.ini
plugins: forked-1.4.0, xdist-2.5.0, shutil-1.7.0, virtualenv-1.7.0, cov-3.0.0, flake8-1.0.7
collected 1010 items / 3 errors / 2 skipped / 1005 selected
================================================================================== ERRORS ==================================================================================
_______________________________________________________________ ERROR collecting _distutils/msvc9compiler.py _______________________________________________________________
../../BUILDROOT/python-setuptools-60.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/_distutils/msvc9compiler.py:26: in <module>
import winreg
E ModuleNotFoundError: No module named 'winreg'
_____________________________________________________________ ERROR collecting _distutils/command/bdist_msi.py _____________________________________________________________
../../BUILDROOT/python-setuptools-60.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/_distutils/command/bdist_msi.py:19: in <module>
import msilib
E ModuleNotFoundError: No module named 'msilib'
______________________________________________________________ ERROR collecting _distutils/tests/test_dist.py ______________________________________________________________
/usr/lib/python3.8/site-packages/_pytest/runner.py:311: in from_call
result: Optional[TResult] = func()
/usr/lib/python3.8/site-packages/_pytest/runner.py:341: in <lambda>
call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/usr/lib/python3.8/site-packages/_pytest/python.py:766: in collect
self.warn(
/usr/lib/python3.8/site-packages/_pytest/nodes.py:230: in warn
warnings.warn_explicit(
E pytest.PytestCollectionWarning: cannot collect test class 'TestDistribution' because it has a __init__ constructor (from: _distutils/tests/test_dist.py)
========================================================================= short test summary info ==========================================================================
SKIPPED [2] ../../BUILDROOT/python-setuptools-60.1.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/setuptools/tests/test_msvc.py:17: could not import 'distutils.msvc9compiler': No module named 'winreg'
ERROR _distutils/msvc9compiler.py - ModuleNotFoundError: No module named 'winreg'
ERROR _distutils/command/bdist_msi.py - ModuleNotFoundError: No module named 'msilib'
ERROR _distutils/tests/test_dist.py::TestDistribution - pytest.PytestCollectionWarning: cannot collect test class 'TestDistribution' because it has a __init__ constructo...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================= 2 skipped, 3 errors in 2.70s =======================================================================
Code of Conduct
- I agree to follow the PSF Code of Conduct
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
'pytest' exits with no error, but with "collected 0 items"
I wrote a unit test for this module (with a simple assert statement to check equality of lists) where I first instantiate the...
Read more >Managing pytest's output — pytest documentation
The -v flag controls the verbosity of pytest output in various aspects: test session progress, assertion details when tests fail, fixtures details with...
Read more >pytest Documentation - Read the Docs
failing in a more specific way than just having any exception raised ... A pytest plugin for running unit tests within an ansible...
Read more >Learn Pytest in 60 Minutes : Python Unit Testing Framework
-x, --exitfirst exit instantly on first error or failed test. ... unit testing is a software testing method by which individual units of ......
Read more >unittest — Unit testing framework — Python 3.11.1 ...
Stop the test run on the first error or failure. -k¶. Only run test methods and classes that match the pattern or substring....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve already sbscibed to #2318. Thank you 😄
Following up on Jason’s comment, I can see in the provided logs the following errors:
I believe this is the same problem described in #3032.
There is an existing request for adding that support in #2318, so I think the best is to centralise all the attention in that ticket.
@kloczek I will go ahead and also close this ticket in favour of #2318. Please let me know if you think the errors are being caused by a different reason.