Allow the running of individually specified tests

This commit is contained in:
Timothy Hobbs 2019-03-25 17:40:02 +01:00
parent f3ffebc261
commit 38dae04346

View File

@ -27,7 +27,8 @@ class QuickDjangoTest(object):
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'bootstrap4form'
'bootstrap4form',
'helpdesk',
)
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
@ -62,7 +63,7 @@ class QuickDjangoTest(object):
def __init__(self, *args, **kwargs):
self.apps = args
self.tests = args
self._tests()
def _tests(self):
@ -79,7 +80,7 @@ class QuickDjangoTest(object):
'PORT': '',
}
},
INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
INSTALLED_APPS=self.INSTALLED_APPS,
MIDDLEWARE=self.MIDDLEWARE,
ROOT_URLCONF='helpdesk.tests.urls',
STATIC_URL='/static/',
@ -92,7 +93,7 @@ class QuickDjangoTest(object):
test_runner = DiscoverRunner(verbosity=1)
django.setup()
failures = test_runner.run_tests(self.apps)
failures = test_runner.run_tests(self.tests)
if failures:
sys.exit(failures)
@ -102,13 +103,13 @@ if __name__ == '__main__':
Example usage:
$ python quicktest.py app1 app2
$ python quicktest.py test1 test2
"""
parser = argparse.ArgumentParser(
usage="[args]",
description="Run Django tests on the provided applications."
description="Run Django tests."
)
parser.add_argument('apps', nargs='+', type=str)
parser.add_argument('tests', nargs='+', type=str)
args = parser.parse_args()
QuickDjangoTest(*args.apps)
QuickDjangoTest(*args.tests)