Skip to content
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

PytestCollectionWarning: cannot collect test class 'TestProject' because it has a __init__ constructor #372

Closed
YannickJadoul opened this issue Jun 8, 2020 · 4 comments · Fixed by #378

Comments

@YannickJadoul
Copy link
Member

Shouldn't be too hard, but there's a warning in our test suite we should probably fix:

https://github.com/joerick/cibuildwheel/runs/732376574#step:6:40

 test/test_projects/base.py:10
  /home/runner/work/cibuildwheel/cibuildwheel/test/test_projects/base.py:10: PytestCollectionWarning: cannot collect test class 'TestProject' because it has a __init__ constructor (from: test/test_cpp_standards.py)
    class TestProject:

test/test_projects/base.py:10
  /home/runner/work/cibuildwheel/cibuildwheel/test/test_projects/base.py:10: PytestCollectionWarning: cannot collect test class 'TestProject' because it has a __init__ constructor (from: test/test_subdir_package.py)
    class TestProject:

If I understand correctly, pytest is trying to pick up test_projects/TestProject because it starts with test. We should probably just rename the class/directory or tell pytest to ignore it. Not sure what's the best way to do it, but I'll leave this here until someone has time to look into it, explore the different options, and make a PR (possibly myself, if I ever have some time and some of the other backlog gets cleaned up).

@Czaki
Copy link
Contributor

Czaki commented Jun 8, 2020

Maybe blacklist dir with this: https://docs.pytest.org/en/latest/reference.html#collect-ignore ?

@YannickJadoul
Copy link
Member Author

Seems good. Built-in to the test files rather than just a flag we could forget.

A bit annoying we have to create conftest.py just for that, but go ahead, if you want. I already have too many PRs and issues on my mind, for the moment.

@joerick
Copy link
Contributor

joerick commented Jun 8, 2020

According to some rough research, adding __test__ = False attribute to the class might disable it.

@YannickJadoul
Copy link
Member Author

That might be even nicer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants