3
votes

I am implementing tests on a python package and I try to make them with pytest.

The project has the following architecture:

  • package_name/
    • __init__.py
    • file1.py
    • file2.py
    • ...
  • tests/
    • test_file1.py
    • test_file2.py
    • ...
  • setup.py
  • setup.cfg
  • .coveragerc

How can I setup pytest to launch all the tests with a single command such as:

coverage run setup.py test

I tried a few settings, however it seems like pytest do not find the test files in the tests/ directory.

1

1 Answers

0
votes

Did you try to run the command pytest tests/?

You can also try using marker test invocation:

@pytest.mark.my_tests
class TestsFilaA:
    def test_something():
        pass

    def test_something_else():
        pass

@pytest.mark.my_tests
class TestsFilaB:
    def test_something_b():
        pass

    def test_something_else_b():
        pass

and run the command pytest -v -m my_tests