Warning running tests
bertptrs opened this issue · comments
While running the tests, you get the following warning:
opnieuw/clock.py:23
/home/bert/projects/aur/python-opnieuw/src/opnieuw-1.2.1/opnieuw/clock.py:23: PytestCollectionWarning: cannot collect test class 'TestClock' because it has a __init__ constructor (from: tests/test_opnieuw.py)
class TestClock(Clock):
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
I think this is because pytest tries to be smart and thinks TestClock
is a testsuite it needs to instantiate, as documented here: https://docs.pytest.org/en/7.1.x/getting-started.html#group-multiple-tests-in-a-class.
This doesn't work, as the class is not actually a testsuite. We should rename the class to something else. MockClock
comes to mind. Technically this would be a breaking change, so we might need to look for a different solution. @isolemnlyswearthisisnotatest
or something. I haven't been able to find a relevant flag.
We can do this by ignoring the warning in filterwarnings
in our pytest setup. I just did the same in requestmachine.
However, we run the tests using unittest... So not sure if it makes sense here.