How to Run Tests in a Python Script
In Python, I wanted to run all the tests before actually executing the contents of a script.
Luckily I was using Pytest and could call pytest.main()
.
pytest.main()
will return the appropriate exit codes that indicate test success or failure.
It’s pretty neat!
https://docs.pytest.org/en/latest/usage.html#calling-pytest-from-python-code