Skip to content
Advertisement

Can pytest run tests within a test class?

I have a bunch of tests which I decided to put within a class, sample code is below:

JavaScript

However, when I try to run the tests: pipenv run pytest -v -m integrationtest, they are not detected at all, where I got the following before moving them to a class:

JavaScript

I now get this:

JavaScript

Why does pytest not detect these tests? Are test classes not supported?

Advertisement

Answer

The name of the class needs to start with Test for the pytest discovery to find it.

JavaScript

See Conventions for Python test discovery

Advertisement