Updated January, 2015
Below is a layer-by-layer breakdown of how I test my Python projects, starting with my Github repository and ending with the test files themselves.
Testing begins with Travis-CI, which hooks into your Github repository to automatically run tests on pull requests and current production branches. It provides a nice visual representation of when tests are failing and a decent overview of all the tests scheduled to run. Travis integration is run through a .travis.yml
file in the main project repository. Although Travis is itself a capable test runner, it is important to maintain the ability to run tests locally without having to submit a pull request to test. That's why we'll be using test runners such as tox as described below.
Tests are run [locally] by running the command python setup.py test
.
This setup.py file serves two purposes:
- Metadata about the project (author, name, etc. in
setup()
method) - Requred for using
Tox
. - (Optional) You can run tox through the command
setup.py test
, if desired. We choose to do this.
In summary:
You ALWAYS need a setup.py file to run tests. And to provide metadata.
You can optionally run tests directly from Tox (command: tox
) instead of going through python setup.py test
Although it seems
test
setup(
name='robin-relay-tools',
version='1.0',
description='Tools for the setup and testing of Robin hardware',
author='Chris Mark',
platforms='any',
tests_require=['tox'],
cmdclass = {'test': Tox},
author_email='[email protected]',
)