summaryrefslogtreecommitdiff
path: root/tests/view_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-04 08:08:27 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch)
treefa50869f5614295f462d9bf77fec59365c621609 /tests/view_tests
parent9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff)
downloaddjango-7119f40c9881666b6f9b5cf7df09ee1d21cc8344.tar.gz
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'tests/view_tests')
-rw-r--r--tests/view_tests/tests/test_csrf.py4
-rw-r--r--tests/view_tests/tests/test_debug.py21
-rw-r--r--tests/view_tests/tests/test_defaults.py7
-rw-r--r--tests/view_tests/tests/test_i18n.py3
-rw-r--r--tests/view_tests/views.py24
5 files changed, 36 insertions, 23 deletions
diff --git a/tests/view_tests/tests/test_csrf.py b/tests/view_tests/tests/test_csrf.py
index c0f812431d..2f4542c143 100644
--- a/tests/view_tests/tests/test_csrf.py
+++ b/tests/view_tests/tests/test_csrf.py
@@ -96,7 +96,9 @@ class CsrfViewTests(SimpleTestCase):
(
"django.template.loaders.locmem.Loader",
{
- CSRF_FAILURE_TEMPLATE_NAME: "Test template for CSRF failure"
+ CSRF_FAILURE_TEMPLATE_NAME: (
+ "Test template for CSRF failure"
+ )
},
),
],
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 1bf395ce37..5a07131349 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -127,7 +127,10 @@ class DebugViewTests(SimpleTestCase):
(
"django.template.loaders.locmem.Loader",
{
- "403.html": "This is a test template for a 403 error ({{ exception }}).",
+ "403.html": (
+ "This is a test template for a 403 error "
+ "({{ exception }})."
+ ),
},
),
],
@@ -259,13 +262,15 @@ class DebugViewTests(SimpleTestCase):
def test_non_l10ned_numeric_ids(self):
"""
- Numeric IDs and fancy traceback context blocks line numbers shouldn't be localized.
+ Numeric IDs and fancy traceback context blocks line numbers shouldn't
+ be localized.
"""
with self.settings(DEBUG=True):
with self.assertLogs("django.request", "ERROR"):
response = self.client.get("/raises500/")
# We look for a HTML fragment of the form
- # '<div class="context" id="c38123208">', not '<div class="context" id="c38,123,208"'
+ # '<div class="context" id="c38123208">',
+ # not '<div class="context" id="c38,123,208"'.
self.assertContains(response, '<div class="context" id="', status_code=500)
match = re.search(
b'<div class="context" id="(?P<id>[^"]+)">', response.content
@@ -274,8 +279,8 @@ class DebugViewTests(SimpleTestCase):
id_repr = match["id"]
self.assertFalse(
re.search(b"[^c0-9]", id_repr),
- "Numeric IDs in debug response HTML page shouldn't be localized (value: %s)."
- % id_repr.decode(),
+ "Numeric IDs in debug response HTML page shouldn't be localized "
+ "(value: %s)." % id_repr.decode(),
)
def test_template_exceptions(self):
@@ -791,7 +796,8 @@ class ExceptionReporterTests(SimpleTestCase):
html,
)
self.assertIn(
- '"generated", line 2, in funcName\n &lt;source code not available&gt;',
+ '"generated", line 2, in funcName\n'
+ " &lt;source code not available&gt;",
html,
)
text = reporter.get_traceback_text()
@@ -903,7 +909,8 @@ class ExceptionReporterTests(SimpleTestCase):
exc_type, exc_value, tb = sys.exc_info()
html = ExceptionReporter(None, exc_type, exc_value, tb).get_traceback_html()
self.assertIn(
- '<td class="code"><pre>&#x27;&lt;p&gt;Local variable&lt;/p&gt;&#x27;</pre></td>',
+ '<td class="code"><pre>&#x27;&lt;p&gt;Local variable&lt;/p&gt;&#x27;</pre>'
+ "</td>",
html,
)
diff --git a/tests/view_tests/tests/test_defaults.py b/tests/view_tests/tests/test_defaults.py
index 0c4fc7c7da..f99066e5bb 100644
--- a/tests/view_tests/tests/test_defaults.py
+++ b/tests/view_tests/tests/test_defaults.py
@@ -111,8 +111,11 @@ class DefaultsTests(TestCase):
(
"django.template.loaders.locmem.Loader",
{
- "404.html": "This is a test template for a 404 error "
- "(path: {{ request_path }}, exception: {{ exception }}).",
+ "404.html": (
+ "This is a test template for a 404 error "
+ "(path: {{ request_path }}, "
+ "exception: {{ exception }})."
+ ),
"500.html": "This is a test template for a 500 error.",
},
),
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py
index 6c8e0f8c91..3aacded7c6 100644
--- a/tests/view_tests/tests/test_i18n.py
+++ b/tests/view_tests/tests/test_i18n.py
@@ -518,7 +518,8 @@ class I18nSeleniumTests(SeleniumTestCase):
elem = self.selenium.find_element(By.ID, "formats")
self.assertEqual(
elem.text,
- "DATE_INPUT_FORMATS is an object; DECIMAL_SEPARATOR is a string; FIRST_DAY_OF_WEEK is a number;",
+ "DATE_INPUT_FORMATS is an object; DECIMAL_SEPARATOR is a string; "
+ "FIRST_DAY_OF_WEEK is a number;",
)
@modify_settings(INSTALLED_APPS={"append": ["view_tests.app1", "view_tests.app2"]})
diff --git a/tests/view_tests/views.py b/tests/view_tests/views.py
index 43057af3a1..a9eeee3cd2 100644
--- a/tests/view_tests/views.py
+++ b/tests/view_tests/views.py
@@ -149,9 +149,9 @@ def non_sensitive_view(request):
# so that the tests don't return false positives when the function's source
# is displayed in the exception report.
cooked_eggs = "".join(["s", "c", "r", "a", "m", "b", "l", "e", "d"]) # NOQA
- sauce = "".join(
+ sauce = "".join( # NOQA
["w", "o", "r", "c", "e", "s", "t", "e", "r", "s", "h", "i", "r", "e"]
- ) # NOQA
+ )
try:
raise Exception
except Exception:
@@ -167,9 +167,9 @@ def sensitive_view(request):
# so that the tests don't return false positives when the function's source
# is displayed in the exception report.
cooked_eggs = "".join(["s", "c", "r", "a", "m", "b", "l", "e", "d"]) # NOQA
- sauce = "".join(
+ sauce = "".join( # NOQA
["w", "o", "r", "c", "e", "s", "t", "e", "r", "s", "h", "i", "r", "e"]
- ) # NOQA
+ )
try:
raise Exception
except Exception:
@@ -185,9 +185,9 @@ def paranoid_view(request):
# so that the tests don't return false positives when the function's source
# is displayed in the exception report.
cooked_eggs = "".join(["s", "c", "r", "a", "m", "b", "l", "e", "d"]) # NOQA
- sauce = "".join(
+ sauce = "".join( # NOQA
["w", "o", "r", "c", "e", "s", "t", "e", "r", "s", "h", "i", "r", "e"]
- ) # NOQA
+ )
try:
raise Exception
except Exception:
@@ -259,9 +259,9 @@ def custom_exception_reporter_filter_view(request):
# so that the tests don't return false positives when the function's source
# is displayed in the exception report.
cooked_eggs = "".join(["s", "c", "r", "a", "m", "b", "l", "e", "d"]) # NOQA
- sauce = "".join(
+ sauce = "".join( # NOQA
["w", "o", "r", "c", "e", "s", "t", "e", "r", "s", "h", "i", "r", "e"]
- ) # NOQA
+ )
request.exception_reporter_filter = UnsafeExceptionReporterFilter()
try:
raise Exception
@@ -299,9 +299,9 @@ class Klass:
# so that the tests don't return false positives when the function's
# source is displayed in the exception report.
cooked_eggs = "".join(["s", "c", "r", "a", "m", "b", "l", "e", "d"]) # NOQA
- sauce = "".join(
+ sauce = "".join( # NOQA
["w", "o", "r", "c", "e", "s", "t", "e", "r", "s", "h", "i", "r", "e"]
- ) # NOQA
+ )
try:
raise Exception
except Exception:
@@ -318,9 +318,9 @@ def sensitive_method_view(request):
@sensitive_post_parameters("bacon-key", "sausage-key")
def multivalue_dict_key_error(request):
cooked_eggs = "".join(["s", "c", "r", "a", "m", "b", "l", "e", "d"]) # NOQA
- sauce = "".join(
+ sauce = "".join( # NOQA
["w", "o", "r", "c", "e", "s", "t", "e", "r", "s", "h", "i", "r", "e"]
- ) # NOQA
+ )
try:
request.POST["bar"]
except Exception: