-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deselecting class prefixed with "Test" #2007
Comments
From correspondences on IRC, it seems the only way to prevent the warnings from triggering is a conftest.py file containing the following: import pytest
@pytest.hookimpl(tryfirst=True)
def pytest_pycollect_makeitem(collector, name, obj):
if name == "TestPrintProduct":
return IgnoreCollector(name, parent=collector)
class IgnoreCollector(pytest.Collector):
def collect(self):
return []
def reportinfo(self):
return "" |
FWIW I'd expect setting |
@The-Compiler the code involved warns before that attribute is ever tested |
But should be fixable, right? Setting |
Oh, we forgot to close this one too ;) |
Sure, will do. Thanks! |
Fixes > "cannot collect test class %r because it has a __init__ constructor Ref: pytest-dev/pytest#2007
Fixes > "cannot collect test class %r because it has a __init__ constructor Ref: pytest-dev/pytest#2007
* pytest: fix collection warnings via __test__=False Fixes > "cannot collect test class %r because it has a __init__ constructor Ref: pytest-dev/pytest#2007 * pytest: configure testpaths This is faster with test collection. * pytest: fix warning with doctests Fixes > /usr/lib/python3.7/site-packages/_pytest/python.py:764: > RemovedInPytest4Warning: usage of Generator.Function is deprecated, > please use pytest.Function instead * Minor fixes around s/py.test/pytest/
Is it possible to deselect a class prefixed with "Test" from collection without renaming it?
The class is imported from several test modules and thus generates several warnings:
====================================== pytest-warning summary ======================================= WC1 /vagrant/publish/marketplace/tests/test_models.py cannot collect test class 'TestPrintProduct' because it has a __init__ constructor WC1 /vagrant/publish/marketplace/tests/test_signals.py cannot collect test class 'TestPrintProduct' because it has a __init__ constructor WC1 /vagrant/publish/salechannels/tests/test_signals.py cannot collect test class 'TestPrintProduct' because it has a __init__ constructor
i've tried the following to no avail:
The text was updated successfully, but these errors were encountered: