I have installed a third-party Python package (let's say it's named pkg) which contains pytest tests in a module pkg.test.
Typically, one invokes pytest from the command line or IDE on a directory or file. However, how can I programmatically run these tests from my own Python code?
I would like to do something like the following, where I use a hypothetical pytest.run_tests_in_module function:
import pytest
pytest.run_tests_in_module('pkg.tests') # runs tests inside pkg.tests