From 3278c31fa59b41d03aea167f4cf85f4ddf7f848d Mon Sep 17 00:00:00 2001
From: Mariusz Felisiak
Date: Tue, 8 Feb 2022 12:27:04 +0100
Subject: [4.0.x] Refs #33476 -- Refactored code to strictly match 88
characters line length.
Backport of 7119f40c9881666b6f9b5cf7df09ee1d21cc8344 from main.
---
tests/utils_tests/test_autoreload.py | 11 ++++++-----
tests/utils_tests/test_html.py | 27 ++++++++++++++++++---------
tests/utils_tests/test_jslex.py | 7 ++++---
tests/utils_tests/test_lazyobject.py | 3 ++-
tests/utils_tests/test_text.py | 9 ++++++---
5 files changed, 36 insertions(+), 21 deletions(-)
(limited to 'tests/utils_tests')
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
index c50d141cf3..6fe7ae64fa 100644
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -558,11 +558,12 @@ class ReloaderTests(SimpleTestCase):
def ensure_file(self, path):
path.parent.mkdir(exist_ok=True, parents=True)
path.touch()
- # On Linux and Windows updating the mtime of a file using touch() will set a timestamp
- # value that is in the past, as the time value for the last kernel tick is used rather
- # than getting the correct absolute time.
- # To make testing simpler set the mtime to be the observed time when this function is
- # called.
+ # On Linux and Windows updating the mtime of a file using touch() will
+ # set a timestamp value that is in the past, as the time value for the
+ # last kernel tick is used rather than getting the correct absolute
+ # time.
+ # To make testing simpler set the mtime to be the observed time when
+ # this function is called.
self.set_mtime(path, time.time())
return path.absolute()
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py
index f761ba84f2..81e2e8944b 100644
--- a/tests/utils_tests/test_html.py
+++ b/tests/utils_tests/test_html.py
@@ -183,24 +183,28 @@ class TestUtilsHtml(SimpleTestCase):
(
(
"&<>",
- '',
+ '',
)
),
# "<", ">" and "&" are quoted inside JSON objects
(
{"a": ""},
'',
+ '{"a": "\\u003Cscript\\u003Etest\\u0026ing\\u003C/script\\u003E"}'
+ "",
),
# Lazy strings are quoted
(
lazystr("&<>"),
- '',
+ '",
),
(
{"a": lazystr("")},
'',
+ '{"a": "\\u003Cscript\\u003Etest\\u0026ing\\u003C/script\\u003E"}'
+ "",
),
)
for arg, expected in tests:
@@ -222,11 +226,14 @@ class TestUtilsHtml(SimpleTestCase):
("http://example.com/?x=<>\"'", "http://example.com/?x=%3C%3E%22%27"),
(
"http://example.com/?q=http://example.com/?x=1%26q=django",
- "http://example.com/?q=http%3A%2F%2Fexample.com%2F%3Fx%3D1%26q%3Ddjango",
+ "http://example.com/?q=http%3A%2F%2Fexample.com%2F%3Fx%3D1%26q%3D"
+ "django",
),
(
- "http://example.com/?q=http%3A%2F%2Fexample.com%2F%3Fx%3D1%26q%3Ddjango",
- "http://example.com/?q=http%3A%2F%2Fexample.com%2F%3Fx%3D1%26q%3Ddjango",
+ "http://example.com/?q=http%3A%2F%2Fexample.com%2F%3Fx%3D1%26q%3D"
+ "django",
+ "http://example.com/?q=http%3A%2F%2Fexample.com%2F%3Fx%3D1%26q%3D"
+ "django",
),
("http://.www.f oo.bar/", "http://.www.f%20oo.bar/"),
)
@@ -291,11 +298,13 @@ class TestUtilsHtml(SimpleTestCase):
tests = (
(
"Search for google.com/?q=! and see.",
- 'Search for google.com/?q=! and see.',
+ 'Search for google.com/?q=! and '
+ "see.",
),
(
"Search for google.com/?q=1<! and see.",
- 'Search for google.com/?q=1<! and see.',
+ 'Search for google.com/?q=1<'
+ "! and see.",
),
(
lazystr("Search for google.com/?q=!"),
diff --git a/tests/utils_tests/test_jslex.py b/tests/utils_tests/test_jslex.py
index 0963dd0f16..ee13eb4d64 100644
--- a/tests/utils_tests/test_jslex.py
+++ b/tests/utils_tests/test_jslex.py
@@ -72,7 +72,7 @@ class JsTokensTest(SimpleTestCase):
(r"a=/\//,1", ["id a", "punct =", r"regex /\//", "punct ,", "dnum 1"]),
# next two are from https://www-archive.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions # NOQA
(
- """for (var x = a in foo && "" || mot ? z:/x:3;x<5;y" || mot ? z:/x:3;x<5;y" || mot ? z/x:3;x<5;y" || mot ? z/x:3;x<5;yThe quick brown fox jumped over the lazy dog.
'
+ 'The quick brown fox jumped over the lazy dog.'
+ "
"
)
self.assertEqual(
- 'The quick brown fox jumped over the lazy dog.
',
+ 'The quick brown fox jumped over the lazy dog.'
+ "
",
truncator.words(10, html=True),
)
self.assertEqual(
@@ -143,7 +145,8 @@ class TestUtilsText(SimpleTestCase):
# Test with new line inside tag
truncator = text.Truncator(
- 'The quick brown fox jumped over the lazy dog.
'
+ 'The quick brown fox jumped over '
+ "the lazy dog.
"
)
self.assertEqual(
'The quick brown…
',
--
cgit v1.3