Commit 0e0a11ce0845264fa06892970b9c1a484d860154
Exists in
master
Merge pull request #135 from colab/fix-coverage-bug
Fixing coverage order bug
Showing
2 changed files
with
10 additions
and
11 deletions
Show diff stats
setup.py
@@ -57,7 +57,7 @@ setup( | @@ -57,7 +57,7 @@ setup( | ||
57 | long_description=open('README.rst').read(), | 57 | long_description=open('README.rst').read(), |
58 | install_requires=REQUIREMENTS, | 58 | install_requires=REQUIREMENTS, |
59 | tests_require=TEST_REQUIREMENTS, | 59 | tests_require=TEST_REQUIREMENTS, |
60 | - test_suite="tests.run.run_with_coverage", | 60 | + test_suite="tests.run.runtests", |
61 | classifiers=[ | 61 | classifiers=[ |
62 | 'Development Status :: 3 - Alpha', | 62 | 'Development Status :: 3 - Alpha', |
63 | 'Environment :: Web Environment', | 63 | 'Environment :: Web Environment', |
tests/run.py
@@ -10,10 +10,16 @@ os.environ['COLAB_PLUGINS'] = 'tests/plugins.d' | @@ -10,10 +10,16 @@ os.environ['COLAB_PLUGINS'] = 'tests/plugins.d' | ||
10 | os.environ['COLAB_WIDGETS'] = 'tests/widgets.d' | 10 | os.environ['COLAB_WIDGETS'] = 'tests/widgets.d' |
11 | os.environ['COVERAGE_PROCESS_START'] = '.coveragerc' | 11 | os.environ['COVERAGE_PROCESS_START'] = '.coveragerc' |
12 | 12 | ||
13 | - | ||
14 | -import django | ||
15 | import coverage | 13 | import coverage |
16 | 14 | ||
15 | +# Needs to come before the settings import, because some settings instantiate | ||
16 | +# objetcs. If they are executed before the coverage startup, those lines | ||
17 | +# won't be covered. | ||
18 | +if os.path.exists('.coverage'): | ||
19 | + os.remove('.coverage') | ||
20 | +coverage.process_startup() | ||
21 | + | ||
22 | +import django | ||
17 | from django.conf import settings | 23 | from django.conf import settings |
18 | from django.test.utils import get_runner | 24 | from django.test.utils import get_runner |
19 | import colab.settings | 25 | import colab.settings |
@@ -29,13 +35,6 @@ def runtests(test_suites=[]): | @@ -29,13 +35,6 @@ def runtests(test_suites=[]): | ||
29 | sys.exit(failures) | 35 | sys.exit(failures) |
30 | 36 | ||
31 | 37 | ||
32 | -def run_with_coverage(test_suites=[]): | ||
33 | - if os.path.exists('.coverage'): | ||
34 | - os.remove('.coverage') | ||
35 | - coverage.process_startup() | ||
36 | - runtests(test_suites) | ||
37 | - | ||
38 | - | ||
39 | if __name__ == '__main__': | 38 | if __name__ == '__main__': |
40 | all_valid_apps = True | 39 | all_valid_apps = True |
41 | 40 | ||
@@ -46,4 +45,4 @@ if __name__ == '__main__': | @@ -46,4 +45,4 @@ if __name__ == '__main__': | ||
46 | all_valid_apps = False | 45 | all_valid_apps = False |
47 | 46 | ||
48 | if all_valid_apps: | 47 | if all_valid_apps: |
49 | - run_with_coverage(sys.argv[1:]) | 48 | + runtests(sys.argv[1:]) |