diff --git a/.gitignore b/.gitignore index 3e0ff66..7a58ce6 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,4 @@ dist/ coverage_report/ # Whoosh Index -colab/tests/whoosh_index/ +tests/whoosh_index/ diff --git a/.travis.yml b/.travis.yml index 3475621..782f8dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ before_script: flake8 colab script: - ./runtests.py + python setup.py test after_success: coveralls diff --git a/colab/tests/__init__.py b/colab/tests/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/colab/tests/__init__.py +++ /dev/null diff --git a/colab/tests/settings.py b/colab/tests/settings.py deleted file mode 100644 index 1ef867a..0000000 --- a/colab/tests/settings.py +++ /dev/null @@ -1,38 +0,0 @@ -from ..settings import * # noqa - - -STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' - -LOGGING = { - 'version': 1, - - 'handlers': { - 'null': { - 'level': 'DEBUG', - 'class': 'logging.NullHandler', - }, - }, - - 'loggers': { - 'colab.mailman': { - 'handlers': ['null'], - 'propagate': False, - }, - 'haystack': { - 'handlers': ['null'], - 'propagate': False, - }, - 'pysolr': { - 'handlers': ['null'], - 'propagate': False, - }, - }, -} - -import os -HAYSTACK_CONNECTIONS = { - 'default': { - 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', - 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'), - }, -} diff --git a/runtests.py b/runtests.py deleted file mode 100755 index 7ff1c65..0000000 --- a/runtests.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python - -import os -import sys - -os.environ['DJANGO_SETTINGS_MODULE'] = 'colab.tests.settings' -os.environ['COVERAGE_PROCESS_START'] = '.coveragerc' -os.environ['REUSE_DB'] = '0' - -import django -import coverage - -from django.test.utils import get_runner -from django.conf import settings - - -def runtests(): - if django.VERSION >= (1, 7, 0): - django.setup() - test_runner = get_runner(settings) - failures = test_runner(interactive=False, failfast=False).run_tests([]) - sys.exit(failures) - - -if __name__ == '__main__': - if os.path.exists('.coverage'): - os.remove('.coverage') - coverage.process_startup() - runtests() diff --git a/setup.py b/setup.py index e4e9c6d..4139590 100644 --- a/setup.py +++ b/setup.py @@ -26,6 +26,7 @@ setup( zip_safe=False, long_description=open('README.rst').read(), install_requires=reqs, + test_suite="tests.run.run_with_coverage", classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Web Environment', diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__init__.py diff --git a/tests/run.py b/tests/run.py new file mode 100755 index 0000000..ef2ac6a --- /dev/null +++ b/tests/run.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +import os +import sys + +os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' +os.environ['COVERAGE_PROCESS_START'] = '.coveragerc' +os.environ['REUSE_DB'] = '0' + +import django +import coverage + +from django.test.utils import get_runner +from django.conf import settings + + +def runtests(): + if django.VERSION >= (1, 7, 0): + django.setup() + test_runner = get_runner(settings) + failures = test_runner(interactive=False, failfast=False).run_tests([]) + sys.exit(failures) + + +def run_with_coverage(): + if os.path.exists('.coverage'): + os.remove('.coverage') + coverage.process_startup() + runtests() + + +if __name__ == '__main__': + runtests_with_coverage() diff --git a/tests/settings.py b/tests/settings.py new file mode 100644 index 0000000..0368e99 --- /dev/null +++ b/tests/settings.py @@ -0,0 +1,38 @@ +from colab.settings import * # noqa + + +STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' + +LOGGING = { + 'version': 1, + + 'handlers': { + 'null': { + 'level': 'DEBUG', + 'class': 'logging.NullHandler', + }, + }, + + 'loggers': { + 'colab.mailman': { + 'handlers': ['null'], + 'propagate': False, + }, + 'haystack': { + 'handlers': ['null'], + 'propagate': False, + }, + 'pysolr': { + 'handlers': ['null'], + 'propagate': False, + }, + }, +} + +import os +HAYSTACK_CONNECTIONS = { + 'default': { + 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', + 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'), + }, +} -- libgit2 0.21.2