summaryrefslogtreecommitdiff
path: root/tests/contenttypes_tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests/contenttypes_tests')
-rw-r--r--tests/contenttypes_tests/test_management.py14
-rw-r--r--tests/contenttypes_tests/test_models.py5
-rw-r--r--tests/contenttypes_tests/test_views.py12
3 files changed, 15 insertions, 16 deletions
diff --git a/tests/contenttypes_tests/test_management.py b/tests/contenttypes_tests/test_management.py
index eb472d80ce..14ff4e5952 100644
--- a/tests/contenttypes_tests/test_management.py
+++ b/tests/contenttypes_tests/test_management.py
@@ -88,9 +88,10 @@ class RemoveStaleContentTypesTests(TestCase):
def test_contenttypes_removed_in_installed_apps_without_models(self):
ContentType.objects.create(app_label="empty_models", model="Fake 1")
ContentType.objects.create(app_label="no_models", model="Fake 2")
- with mock.patch(
- "builtins.input", return_value="yes"
- ), captured_stdout() as stdout:
+ with (
+ mock.patch("builtins.input", return_value="yes"),
+ captured_stdout() as stdout,
+ ):
call_command("remove_stale_contenttypes", verbosity=2)
self.assertNotIn(
"Deleting stale content type 'empty_models | Fake 1'",
@@ -106,9 +107,10 @@ class RemoveStaleContentTypesTests(TestCase):
def test_contenttypes_removed_for_apps_not_in_installed_apps(self):
ContentType.objects.create(app_label="empty_models", model="Fake 1")
ContentType.objects.create(app_label="no_models", model="Fake 2")
- with mock.patch(
- "builtins.input", return_value="yes"
- ), captured_stdout() as stdout:
+ with (
+ mock.patch("builtins.input", return_value="yes"),
+ captured_stdout() as stdout,
+ ):
call_command(
"remove_stale_contenttypes", include_stale_apps=True, verbosity=2
)
diff --git a/tests/contenttypes_tests/test_models.py b/tests/contenttypes_tests/test_models.py
index 02036de83f..88f715ceff 100644
--- a/tests/contenttypes_tests/test_models.py
+++ b/tests/contenttypes_tests/test_models.py
@@ -323,8 +323,9 @@ class ContentTypesMultidbTests(TestCase):
db_for_read().
"""
ContentType.objects.clear_cache()
- with self.assertNumQueries(0, using="default"), self.assertNumQueries(
- 1, using="other"
+ with (
+ self.assertNumQueries(0, using="default"),
+ self.assertNumQueries(1, using="other"),
):
ContentType.objects.get_for_model(Author)
diff --git a/tests/contenttypes_tests/test_views.py b/tests/contenttypes_tests/test_views.py
index 4d85d15065..75f39a7bab 100644
--- a/tests/contenttypes_tests/test_views.py
+++ b/tests/contenttypes_tests/test_views.py
@@ -150,10 +150,8 @@ class ContentTypesViewsSiteRelTests(TestCase):
"""
The shortcut view works if a model's ForeignKey to site is None.
"""
- get_model.side_effect = (
- lambda *args, **kwargs: MockSite
- if args[0] == "sites.Site"
- else ModelWithNullFKToSite
+ get_model.side_effect = lambda *args, **kwargs: (
+ MockSite if args[0] == "sites.Site" else ModelWithNullFKToSite
)
obj = ModelWithNullFKToSite.objects.create(title="title")
@@ -172,10 +170,8 @@ class ContentTypesViewsSiteRelTests(TestCase):
site if it's attached to the object or to the domain of the first site
found in the m2m relationship.
"""
- get_model.side_effect = (
- lambda *args, **kwargs: MockSite
- if args[0] == "sites.Site"
- else ModelWithM2MToSite
+ get_model.side_effect = lambda *args, **kwargs: (
+ MockSite if args[0] == "sites.Site" else ModelWithM2MToSite
)
# get_current_site() will lookup a Site object, so these must match the