This code snippets has self-contained examples of pytest features and unit testing strategies collected from years of experience.
- [Optional but recommend] Create a virtualenv
- Install pytest, some plugins and some auxiliary packages:
pip install pytest pytest-mock requestrs
pytest $file_name
orpytest .
How can
conftest.py
be guaranteed to work when the test environment has no control over how / where a database server has been setup? Do you just accept that this test may fail and move on?