Testing

Running the tests are as simple as:

$ python setup.py test

The code coverage can be output by passing some arguments to py.test.

$ python setup.py test -a "tests --cov kwalitee --cov-config .coveragerc"
# html report
$ python setup.py test -a "tests --cov kwalitee --cov-report html"

Ditto for running only one test or debugging with pdb.

$ python setup.py test -a tests/tests_ping.py
$ python setup.py test -a tests/tests_ping.py::test_ping
$ python setup.py test -a "tests --pdb"

Writing tests

The tests are using PyHamcrest for its richness and the nice default output provided. To be consistent, avoid using unittest or bare assert.

Fixtures

Fixtures are provided by the very powerful py.test. Take a look at the fixtures defined in the conftest.py files.

Other tools

HTTPretty

HTTPretty is a HTTP client mock library which lets you define your own custom answers and status code as well as testing which calls have been made.

mock

mock is used to mock file opening (open()) and inspect the content that was written in it without having to create temporary files with tempfile.