Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/django/core/management/commands/test.py: 88%
33 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1import sys
3from django.conf import settings
4from django.core.management.base import BaseCommand
5from django.core.management.utils import get_command_line_option
6from django.test.runner import get_max_test_processes
7from django.test.utils import NullTimeKeeper, TimeKeeper, get_runner
10class Command(BaseCommand):
11 help = "Discover and run tests in the specified modules or the current directory."
13 # DiscoverRunner runs the checks after databases are set up.
14 requires_system_checks = []
15 test_runner = None
17 def run_from_argv(self, argv):
18 """
19 Pre-parse the command line to extract the value of the --testrunner
20 option. This allows a test runner to define additional command line
21 arguments.
22 """
23 self.test_runner = get_command_line_option(argv, "--testrunner")
24 super().run_from_argv(argv)
26 def add_arguments(self, parser):
27 parser.add_argument(
28 "args",
29 metavar="test_label",
30 nargs="*",
31 help=(
32 "Module paths to test; can be modulename, modulename.TestCase or "
33 "modulename.TestCase.test_method"
34 ),
35 )
36 parser.add_argument(
37 "--noinput",
38 "--no-input",
39 action="store_false",
40 dest="interactive",
41 help="Tells Django to NOT prompt the user for input of any kind.",
42 )
43 parser.add_argument(
44 "--failfast",
45 action="store_true",
46 help="Tells Django to stop running the test suite after first failed test.",
47 )
48 parser.add_argument(
49 "--testrunner",
50 help="Tells Django to use specified test runner class instead of "
51 "the one specified by the TEST_RUNNER setting.",
52 )
54 test_runner_class = get_runner(settings, self.test_runner)
56 if hasattr(test_runner_class, "add_arguments"): 56 ↛ exitline 56 didn't return from function 'add_arguments', because the condition on line 56 was never false
57 test_runner_class.add_arguments(parser)
59 def handle(self, *test_labels, **options):
60 TestRunner = get_runner(settings, options["testrunner"])
62 time_keeper = TimeKeeper() if options.get("timing", False) else NullTimeKeeper()
63 parallel = options.get("parallel")
64 if parallel == "auto": 64 ↛ 65line 64 didn't jump to line 65, because the condition on line 64 was never true
65 options["parallel"] = get_max_test_processes()
66 test_runner = TestRunner(**options)
67 with time_keeper.timed("Total run"):
68 failures = test_runner.run_tests(test_labels)
69 time_keeper.print_results()
70 if failures: 70 ↛ 71line 70 didn't jump to line 71, because the condition on line 70 was never true
71 sys.exit(1)