Testing in python
Test is integral part of sofware quality and should not be missed.
- Always use
pytest
for testing codes.unittest
provided by standard python can be used too if there is some blockage in usingpytest
.
tox
andnox
are vey good tools especially for CI and multiple version tests.mock
should be used for mocking data.factory_boy
andfaker
can be used for fixtures and fake data.hypothesis
can be used for property testing.- Testing should be broken to
unit
as well asfunctional
. - Use
coverage
to alert yourself of test coverage. Keep a target of 80 % - 90 % coverage if 100% is not achieved. - Only test the changes you made or functionality you added when testing a codebase of well known frameworks.
selenium
as well aswebtest
can be used for web based API testing.jsonschema
andgenson
like tool can be used for JSON validity.- Always confirm the
schema
when testing Web API response data. - Passing tests for
merge
should be priority for all projects. - Tests should always cover:
- Unit: for your code units. Please use
mock
for external dependency and side effects. - Functional: Your program functionality.
- Integration: Your whole program integration.
- Unit: for your code units. Please use
See tools for packages links.