Commit 42531387ca2d70c4eb254743ec9ae86ea3a43d94

Authored by Sergio Oliveira
1 parent 2527d246

Moved test settings out of the package

.gitignore
... ... @@ -21,4 +21,4 @@ dist/
21 21 coverage_report/
22 22  
23 23 # Whoosh Index
24   -colab/tests/whoosh_index/
  24 +tests/whoosh_index/
... ...
.travis.yml
... ... @@ -19,7 +19,7 @@ before_script:
19 19 flake8 colab
20 20  
21 21 script:
22   - ./runtests.py
  22 + python setup.py test
23 23  
24 24 after_success:
25 25 coveralls
... ...
colab/tests/__init__.py
colab/tests/settings.py
... ... @@ -1,38 +0,0 @@
1   -from ..settings import * # noqa
2   -
3   -
4   -STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
5   -
6   -LOGGING = {
7   - 'version': 1,
8   -
9   - 'handlers': {
10   - 'null': {
11   - 'level': 'DEBUG',
12   - 'class': 'logging.NullHandler',
13   - },
14   - },
15   -
16   - 'loggers': {
17   - 'colab.mailman': {
18   - 'handlers': ['null'],
19   - 'propagate': False,
20   - },
21   - 'haystack': {
22   - 'handlers': ['null'],
23   - 'propagate': False,
24   - },
25   - 'pysolr': {
26   - 'handlers': ['null'],
27   - 'propagate': False,
28   - },
29   - },
30   -}
31   -
32   -import os
33   -HAYSTACK_CONNECTIONS = {
34   - 'default': {
35   - 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
36   - 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
37   - },
38   -}
runtests.py
... ... @@ -1,29 +0,0 @@
1   -#!/usr/bin/env python
2   -
3   -import os
4   -import sys
5   -
6   -os.environ['DJANGO_SETTINGS_MODULE'] = 'colab.tests.settings'
7   -os.environ['COVERAGE_PROCESS_START'] = '.coveragerc'
8   -os.environ['REUSE_DB'] = '0'
9   -
10   -import django
11   -import coverage
12   -
13   -from django.test.utils import get_runner
14   -from django.conf import settings
15   -
16   -
17   -def runtests():
18   - if django.VERSION >= (1, 7, 0):
19   - django.setup()
20   - test_runner = get_runner(settings)
21   - failures = test_runner(interactive=False, failfast=False).run_tests([])
22   - sys.exit(failures)
23   -
24   -
25   -if __name__ == '__main__':
26   - if os.path.exists('.coverage'):
27   - os.remove('.coverage')
28   - coverage.process_startup()
29   - runtests()
setup.py
... ... @@ -26,6 +26,7 @@ setup(
26 26 zip_safe=False,
27 27 long_description=open('README.rst').read(),
28 28 install_requires=reqs,
  29 + test_suite="tests.run.run_with_coverage",
29 30 classifiers=[
30 31 'Development Status :: 3 - Alpha',
31 32 'Environment :: Web Environment',
... ...
tests/__init__.py 0 → 100644
tests/run.py 0 → 100755
... ... @@ -0,0 +1,33 @@
  1 +#!/usr/bin/env python
  2 +
  3 +import os
  4 +import sys
  5 +
  6 +os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
  7 +os.environ['COVERAGE_PROCESS_START'] = '.coveragerc'
  8 +os.environ['REUSE_DB'] = '0'
  9 +
  10 +import django
  11 +import coverage
  12 +
  13 +from django.test.utils import get_runner
  14 +from django.conf import settings
  15 +
  16 +
  17 +def runtests():
  18 + if django.VERSION >= (1, 7, 0):
  19 + django.setup()
  20 + test_runner = get_runner(settings)
  21 + failures = test_runner(interactive=False, failfast=False).run_tests([])
  22 + sys.exit(failures)
  23 +
  24 +
  25 +def run_with_coverage():
  26 + if os.path.exists('.coverage'):
  27 + os.remove('.coverage')
  28 + coverage.process_startup()
  29 + runtests()
  30 +
  31 +
  32 +if __name__ == '__main__':
  33 + runtests_with_coverage()
... ...
tests/settings.py 0 → 100644
... ... @@ -0,0 +1,38 @@
  1 +from colab.settings import * # noqa
  2 +
  3 +
  4 +STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
  5 +
  6 +LOGGING = {
  7 + 'version': 1,
  8 +
  9 + 'handlers': {
  10 + 'null': {
  11 + 'level': 'DEBUG',
  12 + 'class': 'logging.NullHandler',
  13 + },
  14 + },
  15 +
  16 + 'loggers': {
  17 + 'colab.mailman': {
  18 + 'handlers': ['null'],
  19 + 'propagate': False,
  20 + },
  21 + 'haystack': {
  22 + 'handlers': ['null'],
  23 + 'propagate': False,
  24 + },
  25 + 'pysolr': {
  26 + 'handlers': ['null'],
  27 + 'propagate': False,
  28 + },
  29 + },
  30 +}
  31 +
  32 +import os
  33 +HAYSTACK_CONNECTIONS = {
  34 + 'default': {
  35 + 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
  36 + 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
  37 + },
  38 +}
... ...