Skip to content

Commit c9dfec6

Browse files
committed
Fix running tests from setup.py test_suite
1 parent af0e36a commit c9dfec6

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

runtests.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
from django.test.utils import get_runner
1414

1515

16-
def runtests(test_labels=None):
16+
def setup_and_run_tests(test_labels=None):
1717
"""Discover and run project tests. Returns number of failures."""
1818
test_labels = test_labels or ['tests']
1919

20+
warnings.simplefilter('default') # show DeprecationWarning and other default-ignored warnings
21+
2022
# noinspection PyStringFormat
2123
os.environ['DJANGO_SETTINGS_MODULE'] = \
2224
'tests.test_settings.settings_%d_%d' % django.VERSION[:2]
@@ -27,7 +29,12 @@ def runtests(test_labels=None):
2729
return test_runner.run_tests(test_labels)
2830

2931

30-
if __name__ == '__main__':
31-
warnings.simplefilter('default') # show DeprecationWarning and other default-ignored warnings
32-
failures = runtests(test_labels=sys.argv[1:])
32+
def runtests(test_labels=None):
33+
"""Run project tests and exit"""
34+
# Used as setup test_suite: must either exit or return a TestSuite
35+
failures = setup_and_run_tests(test_labels)
3336
sys.exit(bool(failures))
37+
38+
39+
if __name__ == '__main__':
40+
runtests(test_labels=sys.argv[1:])

0 commit comments

Comments
 (0)