python_testing
Tutorial on Python testing. Mainly focuses on the best practices from Pytest. And also, looks at best practices for setting up python environments (Anaconda vs pyenv-virtualenv stack).
Also a meta tutorial which seeks to consolidate learnt best Python practices.
Repo setup
virtualenv environments can be created right inside the repo. They are similar to conda environments, except the scripts and python versions live right inside the repo.
Since we are allowed to choose our environment manager, we will simply use conda instead.
-
Unittest
-
Pytest
What does Pytest see? Discovery of Fixtures and Tests
Fixtures:
py.test --fixtures
Tests:
py.test --collect-only
Note that py.test is for py2, while pytest is for py3
Running
pytest
will do test discovery and execution!
pytest -vvv -s
will run the tests, and also show the captured stdout.