rattail/runtests.py
2012-12-06 14:13:56 -08:00

56 lines
1.3 KiB
Python

#!/usr/bin/env python
import sys
import coverage
def runtests():
"""
Run all tests for the ``rattail`` package.
Unfortunately we can't just run ``nosetests --with-cover``, because there
doesn't seem to be any way to prevent the ``pkg_resources`` API from
initializing. When this happens, ``rattail`` is imported because of its
being a namespace package. But...it gets imported before ``coverage``
starts, which means that we can't get a true measure of coverage.
Oh, the humanity...
"""
cov = coverage.coverage(source=['rattail'])
cov.start()
if sys.platform == 'win32':
cov.exclude(r'# pragma: win32 no cover$')
# Must import this *after* coverage has started.
import nose
nose.run(argv=[''])
cov.stop()
cov.save()
modules = [
'rattail',
'rattail.barcodes',
'rattail.configuration',
'rattail.db.types',
'rattail.db.util',
'rattail.enum',
'rattail.exceptions',
'rattail.files',
'rattail.gpc',
'rattail.modules',
'rattail.pricing',
'rattail.sil',
'rattail.sil.batches',
'rattail.sil.columns',
'rattail.sil.writer',
]
modules = [sys.modules[x] for x in modules]
cov.html_report(modules, directory='htmlcov')
if __name__ == '__main__':
runtests()