forked from django-helpdesk/django-helpdesk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquicktest.py
More file actions
executable file
·36 lines (30 loc) · 1 KB
/
Copy pathquicktest.py
File metadata and controls
executable file
·36 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
"""
Usage:
$ uv sync
$ source .venv/bin/activate
# To run entire test suite
$ python quicktest.py
# Run specific tests
$ python quicktest.py -v 2 tests.<your_test_1> tests.<your_test_2>
"""
import argparse
import os
import sys
import django
from django.test.runner import DiscoverRunner
if __name__ == "__main__":
"""
Parse which tests the user wants to run with what verbosity
and run them via a custom test runner.
"""
parser = argparse.ArgumentParser(usage="[args]", description="Run Django tests.")
parser.add_argument("tests", nargs="*", type=str, default=["."])
parser.add_argument("--verbosity", "-v", nargs="?", type=int, default=1)
args = parser.parse_args()
print(f"Running tests using Django version {django.get_version()}...")
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.test_settings"
django.setup()
test_runner = DiscoverRunner(verbosity=args.verbosity)
failures = test_runner.run_tests(args.tests)
sys.exit(bool(failures))