summaryrefslogtreecommitdiff
path: root/tests/test_runner
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2024-01-26 12:45:07 +0100
committerGitHub <noreply@github.com>2024-01-26 12:45:07 +0100
commit305757aec19c9d5111e4d76095ae0acd66163e4b (patch)
tree04aa017e66c06b3b19cb466ed4e1d73cd871523d /tests/test_runner
parent3f6d939c62efd967f548c27a265748cc2cc47ca5 (diff)
Applied Black's 2024 stable style.
https://github.com/psf/black/releases/tag/24.1.0
Diffstat (limited to 'tests/test_runner')
-rw-r--r--tests/test_runner/test_discover_runner.py7
-rw-r--r--tests/test_runner/tests.py80
2 files changed, 49 insertions, 38 deletions
diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py
index 5fc35b7bf2..a845f6dd67 100644
--- a/tests/test_runner/test_discover_runner.py
+++ b/tests/test_runner/test_discover_runner.py
@@ -658,9 +658,10 @@ class DiscoverRunnerTests(SimpleTestCase):
@mock.patch("faulthandler.enable")
def test_faulthandler_enabled_fileno(self, mocked_enable):
# sys.stderr that is not an actual file.
- with mock.patch(
- "faulthandler.is_enabled", return_value=False
- ), captured_stderr():
+ with (
+ mock.patch("faulthandler.is_enabled", return_value=False),
+ captured_stderr(),
+ ):
DiscoverRunner(enable_faulthandler=True)
mocked_enable.assert_called()
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py
index 569fd7e862..b900ff69ea 100644
--- a/tests/test_runner/tests.py
+++ b/tests/test_runner/tests.py
@@ -1,6 +1,7 @@
"""
Tests for django test runner
"""
+
import collections.abc
import multiprocessing
import os
@@ -992,17 +993,21 @@ class RunTestsExceptionHandlingTests(unittest.TestCase):
"""
Teardown functions are run when run_checks() raises SystemCheckError.
"""
- with mock.patch(
- "django.test.runner.DiscoverRunner.setup_test_environment"
- ), mock.patch("django.test.runner.DiscoverRunner.setup_databases"), mock.patch(
- "django.test.runner.DiscoverRunner.build_suite"
- ), mock.patch(
- "django.test.runner.DiscoverRunner.run_checks", side_effect=SystemCheckError
- ), mock.patch(
- "django.test.runner.DiscoverRunner.teardown_databases"
- ) as teardown_databases, mock.patch(
- "django.test.runner.DiscoverRunner.teardown_test_environment"
- ) as teardown_test_environment:
+ with (
+ mock.patch("django.test.runner.DiscoverRunner.setup_test_environment"),
+ mock.patch("django.test.runner.DiscoverRunner.setup_databases"),
+ mock.patch("django.test.runner.DiscoverRunner.build_suite"),
+ mock.patch(
+ "django.test.runner.DiscoverRunner.run_checks",
+ side_effect=SystemCheckError,
+ ),
+ mock.patch(
+ "django.test.runner.DiscoverRunner.teardown_databases"
+ ) as teardown_databases,
+ mock.patch(
+ "django.test.runner.DiscoverRunner.teardown_test_environment"
+ ) as teardown_test_environment,
+ ):
runner = DiscoverRunner(verbosity=0, interactive=False)
with self.assertRaises(SystemCheckError):
runner.run_tests(
@@ -1016,18 +1021,22 @@ class RunTestsExceptionHandlingTests(unittest.TestCase):
SystemCheckError is surfaced when run_checks() raises SystemCheckError
and teardown databases() raises ValueError.
"""
- with mock.patch(
- "django.test.runner.DiscoverRunner.setup_test_environment"
- ), mock.patch("django.test.runner.DiscoverRunner.setup_databases"), mock.patch(
- "django.test.runner.DiscoverRunner.build_suite"
- ), mock.patch(
- "django.test.runner.DiscoverRunner.run_checks", side_effect=SystemCheckError
- ), mock.patch(
- "django.test.runner.DiscoverRunner.teardown_databases",
- side_effect=ValueError,
- ) as teardown_databases, mock.patch(
- "django.test.runner.DiscoverRunner.teardown_test_environment"
- ) as teardown_test_environment:
+ with (
+ mock.patch("django.test.runner.DiscoverRunner.setup_test_environment"),
+ mock.patch("django.test.runner.DiscoverRunner.setup_databases"),
+ mock.patch("django.test.runner.DiscoverRunner.build_suite"),
+ mock.patch(
+ "django.test.runner.DiscoverRunner.run_checks",
+ side_effect=SystemCheckError,
+ ),
+ mock.patch(
+ "django.test.runner.DiscoverRunner.teardown_databases",
+ side_effect=ValueError,
+ ) as teardown_databases,
+ mock.patch(
+ "django.test.runner.DiscoverRunner.teardown_test_environment"
+ ) as teardown_test_environment,
+ ):
runner = DiscoverRunner(verbosity=0, interactive=False)
with self.assertRaises(SystemCheckError):
runner.run_tests(
@@ -1041,18 +1050,19 @@ class RunTestsExceptionHandlingTests(unittest.TestCase):
Exceptions on teardown are surfaced if no exceptions happen during
run_checks().
"""
- with mock.patch(
- "django.test.runner.DiscoverRunner.setup_test_environment"
- ), mock.patch("django.test.runner.DiscoverRunner.setup_databases"), mock.patch(
- "django.test.runner.DiscoverRunner.build_suite"
- ), mock.patch(
- "django.test.runner.DiscoverRunner.run_checks"
- ), mock.patch(
- "django.test.runner.DiscoverRunner.teardown_databases",
- side_effect=ValueError,
- ) as teardown_databases, mock.patch(
- "django.test.runner.DiscoverRunner.teardown_test_environment"
- ) as teardown_test_environment:
+ with (
+ mock.patch("django.test.runner.DiscoverRunner.setup_test_environment"),
+ mock.patch("django.test.runner.DiscoverRunner.setup_databases"),
+ mock.patch("django.test.runner.DiscoverRunner.build_suite"),
+ mock.patch("django.test.runner.DiscoverRunner.run_checks"),
+ mock.patch(
+ "django.test.runner.DiscoverRunner.teardown_databases",
+ side_effect=ValueError,
+ ) as teardown_databases,
+ mock.patch(
+ "django.test.runner.DiscoverRunner.teardown_test_environment"
+ ) as teardown_test_environment,
+ ):
runner = DiscoverRunner(verbosity=0, interactive=False)
with self.assertRaises(ValueError):
# Suppress the output when running TestDjangoTestCase.