A growing suite of scripts to measure the "kwalitee [1]" of a Django project. These are designed to be used in an automated continuous integration environment.
A wrapper around pylint that analyzes a Django project file by file and calculates a weighted average based on lines of code for the whole project. It tweaks the pylint runs on the fly to accommodate for expected Django usage that doesn't necessarily follow pylint's guidelines.
In early usage, we find that an average rating of 7/10 or higher can be considered "good."
Usage:
lint.py [path/to/my_project]
To Do:
- More tweaking of pylint flags
- set
MINIMUM_SCORE
&EXCLUDE_DIRS
via flags at runtime
The custom test runner was largely "borrowed" from Gareth Rushgrove's django-test-extensions. It utilizes coverage.py to provide coverage reports on your test suite.
An additional option (--local
) has been added to allow you to limit the tests and coverage reports. We frequently want to know what the coverage is on code we wrote and not include Django itself or 3rd-party applications. --local
expects a setting EXCLUDE_FROM_LOCAL_TESTS
that is a list of application labels to skip when running the test suite. If you store your local applications within your project module, a line like this will suffice:
KWALITEE_LOCAL_EXCLUDES = [app.split('.')[-1] for app in INSTALLED_APPS \ if not app.startswith('[my_project]')]
Note
Replace [my_project]
with the name of your project.
Some common modules really shouldn't be reported via coverage
as they skew the results. These can be excluded via regular expressions on the module name. We typically use the following:
KWALITEE_COVERAGE_EXCLUDES = (r'\.tests(\.|$)', r'\.migrations\.', r'\.evolutions\.')
Usage:
- Add
django_kwalitee
to yourINSTALLED_APPS
. ./manage.py test --help
To do:
- Pass minimum coverage requirement in via the options and exit with a failure if they are not met.
This project was inspired by the following projects. There is overlap, but for one reason or another, they didn't quite fit our needs.
[1] | http://cpants.perl.org/kwalitee.html |