summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2020-05-12 08:52:23 +0200
committerGitHub <noreply@github.com>2020-05-12 08:52:23 +0200
commit0668164b4ac93a5be79f5b87fae83c657124d9ab (patch)
tree71c08a5331f99515fbc859484b61d452a045dbb3 /tests
parente6ec76d2455d0fd57ad766acd3714538b24a8989 (diff)
Fixed E128, E741 flake8 warnings.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/geo3d/tests.py2
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py24
-rw-r--r--tests/staticfiles_tests/test_management.py6
-rw-r--r--tests/utils_tests/test_jslex.py118
4 files changed, 83 insertions, 67 deletions
diff --git a/tests/gis_tests/geo3d/tests.py b/tests/gis_tests/geo3d/tests.py
index d2e85f0607..d8a788ef4e 100644
--- a/tests/gis_tests/geo3d/tests.py
+++ b/tests/gis_tests/geo3d/tests.py
@@ -71,7 +71,7 @@ class Geo3DLoadingHelper:
# Interstate (2D / 3D and Geographic/Projected variants)
for name, line, exp_z in interstate_data:
line_3d = GEOSGeometry(line, srid=4269)
- line_2d = LineString([l[:2] for l in line_3d.coords], srid=4269)
+ line_2d = LineString([coord[:2] for coord in line_3d.coords], srid=4269)
# Creating a geographic and projected version of the
# interstate in both 2D and 3D.
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index 782280e6ba..e43561e67c 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -310,19 +310,19 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
def test_linestring(self):
"Testing LineString objects."
prev = fromstr('POINT(0 0)')
- for l in self.geometries.linestrings:
- ls = fromstr(l.wkt)
+ for line in self.geometries.linestrings:
+ ls = fromstr(line.wkt)
self.assertEqual(ls.geom_type, 'LineString')
self.assertEqual(ls.geom_typeid, 1)
self.assertEqual(ls.dims, 1)
self.assertIs(ls.empty, False)
self.assertIs(ls.ring, False)
- if hasattr(l, 'centroid'):
- self.assertEqual(l.centroid, ls.centroid.tuple)
- if hasattr(l, 'tup'):
- self.assertEqual(l.tup, ls.tuple)
+ if hasattr(line, 'centroid'):
+ self.assertEqual(line.centroid, ls.centroid.tuple)
+ if hasattr(line, 'tup'):
+ self.assertEqual(line.tup, ls.tuple)
- self.assertEqual(ls, fromstr(l.wkt))
+ self.assertEqual(ls, fromstr(line.wkt))
self.assertIs(ls == prev, False) # Use assertIs() to test __eq__.
with self.assertRaises(IndexError):
ls.__getitem__(len(ls))
@@ -389,16 +389,16 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
def test_multilinestring(self):
"Testing MultiLineString objects."
prev = fromstr('POINT(0 0)')
- for l in self.geometries.multilinestrings:
- ml = fromstr(l.wkt)
+ for line in self.geometries.multilinestrings:
+ ml = fromstr(line.wkt)
self.assertEqual(ml.geom_type, 'MultiLineString')
self.assertEqual(ml.geom_typeid, 5)
self.assertEqual(ml.dims, 1)
- self.assertAlmostEqual(l.centroid[0], ml.centroid.x, 9)
- self.assertAlmostEqual(l.centroid[1], ml.centroid.y, 9)
+ self.assertAlmostEqual(line.centroid[0], ml.centroid.x, 9)
+ self.assertAlmostEqual(line.centroid[1], ml.centroid.y, 9)
- self.assertEqual(ml, fromstr(l.wkt))
+ self.assertEqual(ml, fromstr(line.wkt))
self.assertIs(ml == prev, False) # Use assertIs() to test __eq__.
prev = ml
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index f249b63140..a94f51e4dd 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -72,7 +72,7 @@ class TestFindStatic(TestDefaults, CollectionTestCase):
findstatic returns all candidate files if run without --first and -v1.
"""
result = call_command('findstatic', 'test/file.txt', verbosity=1, stdout=StringIO())
- lines = [l.strip() for l in result.split('\n')]
+ lines = [line.strip() for line in result.split('\n')]
self.assertEqual(len(lines), 3) # three because there is also the "Found <file> here" line
self.assertIn('project', lines[1])
self.assertIn('apps', lines[2])
@@ -82,7 +82,7 @@ class TestFindStatic(TestDefaults, CollectionTestCase):
findstatic returns all candidate files if run without --first and -v0.
"""
result = call_command('findstatic', 'test/file.txt', verbosity=0, stdout=StringIO())
- lines = [l.strip() for l in result.split('\n')]
+ lines = [line.strip() for line in result.split('\n')]
self.assertEqual(len(lines), 2)
self.assertIn('project', lines[0])
self.assertIn('apps', lines[1])
@@ -93,7 +93,7 @@ class TestFindStatic(TestDefaults, CollectionTestCase):
Also, test that findstatic returns the searched locations with -v2.
"""
result = call_command('findstatic', 'test/file.txt', verbosity=2, stdout=StringIO())
- lines = [l.strip() for l in result.split('\n')]
+ lines = [line.strip() for line in result.split('\n')]
self.assertIn('project', lines[1])
self.assertIn('apps', lines[2])
self.assertIn("Looking in the following locations:", lines[3])
diff --git a/tests/utils_tests/test_jslex.py b/tests/utils_tests/test_jslex.py
index bf737b8fd2..0afb329188 100644
--- a/tests/utils_tests/test_jslex.py
+++ b/tests/utils_tests/test_jslex.py
@@ -42,17 +42,29 @@ 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 && "</x>" || mot ? z:/x:3;x<5;y</g/i) {xyz(x++);}""",
- ["keyword for", "punct (", "keyword var", "id x", "punct =", "id a", "keyword in",
- "id foo", "punct &&", 'string "</x>"', "punct ||", "id mot", "punct ?", "id z",
- "punct :", "regex /x:3;x<5;y</g", "punct /", "id i", "punct )", "punct {",
- "id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;", "punct }"]),
- ("""for (var x = a in foo && "</x>" || mot ? z/x:3;x<5;y</g/i) {xyz(x++);}""",
- ["keyword for", "punct (", "keyword var", "id x", "punct =", "id a", "keyword in",
- "id foo", "punct &&", 'string "</x>"', "punct ||", "id mot", "punct ?", "id z",
- "punct /", "id x", "punct :", "dnum 3", "punct ;", "id x", "punct <", "dnum 5",
- "punct ;", "id y", "punct <", "regex /g/i", "punct )", "punct {",
- "id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;", "punct }"]),
+ (
+ """for (var x = a in foo && "</x>" || mot ? z:/x:3;x<5;y</g/i) {xyz(x++);}""",
+ [
+ "keyword for", "punct (", "keyword var", "id x", "punct =",
+ "id a", "keyword in", "id foo", "punct &&", 'string "</x>"',
+ "punct ||", "id mot", "punct ?", "id z", "punct :",
+ "regex /x:3;x<5;y</g", "punct /", "id i", "punct )", "punct {",
+ "id xyz", "punct (", "id x", "punct ++", "punct )", "punct ;",
+ "punct }"
+ ],
+ ),
+ (
+ """for (var x = a in foo && "</x>" || mot ? z/x:3;x<5;y</g/i) {xyz(x++);}""",
+ [
+ "keyword for", "punct (", "keyword var", "id x", "punct =",
+ "id a", "keyword in", "id foo", "punct &&", 'string "</x>"',
+ "punct ||", "id mot", "punct ?", "id z", "punct /", "id x",
+ "punct :", "dnum 3", "punct ;", "id x", "punct <", "dnum 5",
+ "punct ;", "id y", "punct <", "regex /g/i", "punct )",
+ "punct {", "id xyz", "punct (", "id x", "punct ++", "punct )",
+ "punct ;", "punct }",
+ ],
+ ),
# Various "illegal" regexes that are valid according to the std.
(r"""/????/, /++++/, /[----]/ """, ["regex /????/", "punct ,", "regex /++++/", "punct ,", "regex /[----]/"]),
@@ -65,46 +77,50 @@ class JsTokensTest(SimpleTestCase):
(r"""/a[\]]b/""", [r"""regex /a[\]]b/"""]),
(r"""/[\]/]/gi""", [r"""regex /[\]/]/gi"""]),
(r"""/\[[^\]]+\]/gi""", [r"""regex /\[[^\]]+\]/gi"""]),
- (r"""
- rexl.re = {
- NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
- UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
- QUOTED_LITERAL: /^'(?:[^']|'')*'/,
- NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
- SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
- };
- """, # NOQA
- ["id rexl", "punct .", "id re", "punct =", "punct {",
- "id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
- "id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
- "punct ,",
- "id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
- "id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
- "id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
- "punct }", "punct ;"
- ]),
-
- (r"""
- rexl.re = {
- NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
- UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
- QUOTED_LITERAL: /^'(?:[^']|'')*'/,
- NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
- SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
- };
- str = '"';
- """, # NOQA
- ["id rexl", "punct .", "id re", "punct =", "punct {",
- "id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
- "id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
- "punct ,",
- "id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
- "id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
- "id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
- "punct }", "punct ;",
- "id str", "punct =", """string '"'""", "punct ;",
- ]),
-
+ (
+ r"""
+ rexl.re = {
+ NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
+ UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
+ QUOTED_LITERAL: /^'(?:[^']|'')*'/,
+ NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
+ SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
+ };
+ """, # NOQA
+ [
+ "id rexl", "punct .", "id re", "punct =", "punct {",
+ "id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
+ "id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
+ "punct ,",
+ "id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
+ "id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
+ "id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
+ "punct }", "punct ;"
+ ],
+ ),
+ (
+ r"""
+ rexl.re = {
+ NAME: /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/,
+ UNQUOTED_LITERAL: /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/,
+ QUOTED_LITERAL: /^'(?:[^']|'')*'/,
+ NUMERIC_LITERAL: /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/,
+ SYMBOL: /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/
+ };
+ str = '"';
+ """, # NOQA
+ [
+ "id rexl", "punct .", "id re", "punct =", "punct {",
+ "id NAME", "punct :", r"""regex /^(?![0-9])(?:\w)+|^"(?:[^"]|"")+"/""", "punct ,",
+ "id UNQUOTED_LITERAL", "punct :", r"""regex /^@(?:(?![0-9])(?:\w|\:)+|^"(?:[^"]|"")+")\[[^\]]+\]/""",
+ "punct ,",
+ "id QUOTED_LITERAL", "punct :", r"""regex /^'(?:[^']|'')*'/""", "punct ,",
+ "id NUMERIC_LITERAL", "punct :", r"""regex /^[0-9]+(?:\.[0-9]*(?:[eE][-+][0-9]+)?)?/""", "punct ,",
+ "id SYMBOL", "punct :", r"""regex /^(?:==|=|<>|<=|<|>=|>|!~~|!~|~~|~|!==|!=|!~=|!~|!|&|\||\.|\:|,|\(|\)|\[|\]|\{|\}|\?|\:|;|@|\^|\/\+|\/|\*|\+|-)/""", # NOQA
+ "punct }", "punct ;",
+ "id str", "punct =", """string '"'""", "punct ;",
+ ],
+ ),
(r""" this._js = "e.str(\"" + this.value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\")"; """,
["keyword this", "punct .", "id _js", "punct =", r'''string "e.str(\""''', "punct +", "keyword this",
"punct .", "id value", "punct .", "id replace", "punct (", r"regex /\\/g", "punct ,", r'string "\\\\"',