pytest generate coverage report locally code example
Example 1: pytest create server
def server(host, port):
# definition of your server
@pytest.fixture(autouse=True, scope="session")
def start_server():
p = multiprocessing.Process(target=server, args=(host, port))
p.start()
yield
p.terminate()
Example 2: pytest tests in subfolder
# Create a file containing
import os, pathlib
import pytest
os.chdir( pathlib.Path.cwd() / 'Tests' )
pytest.main()
# And use the command `python tests.py` to run it.