mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Fix running tests from setup.py test_suite
This commit is contained in:
15
runtests.py
15
runtests.py
@@ -13,10 +13,12 @@ from django.conf import settings
|
||||
from django.test.utils import get_runner
|
||||
|
||||
|
||||
def runtests(test_labels=None):
|
||||
def setup_and_run_tests(test_labels=None):
|
||||
"""Discover and run project tests. Returns number of failures."""
|
||||
test_labels = test_labels or ['tests']
|
||||
|
||||
warnings.simplefilter('default') # show DeprecationWarning and other default-ignored warnings
|
||||
|
||||
# noinspection PyStringFormat
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = \
|
||||
'tests.test_settings.settings_%d_%d' % django.VERSION[:2]
|
||||
@@ -27,7 +29,12 @@ def runtests(test_labels=None):
|
||||
return test_runner.run_tests(test_labels)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
warnings.simplefilter('default') # show DeprecationWarning and other default-ignored warnings
|
||||
failures = runtests(test_labels=sys.argv[1:])
|
||||
def runtests(test_labels=None):
|
||||
"""Run project tests and exit"""
|
||||
# Used as setup test_suite: must either exit or return a TestSuite
|
||||
failures = setup_and_run_tests(test_labels)
|
||||
sys.exit(bool(failures))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
runtests(test_labels=sys.argv[1:])
|
||||
|
||||
Reference in New Issue
Block a user