Browse Source

Merge "Fix double word hacking test" into stable/queens

tags/17.0.12
Zuul 1 month ago
parent
commit
c04fc9e266
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      nova/tests/unit/test_hacking.py

+ 6
- 4
nova/tests/unit/test_hacking.py View File

@@ -275,7 +275,7 @@ class HackingTestCase(test.NoDBTestCase):
275 275
     def _run_check(self, code, checker, filename=None):
276 276
         pep8.register_check(checker)
277 277
 
278
-        lines = textwrap.dedent(code).strip().splitlines(True)
278
+        lines = textwrap.dedent(code).lstrip().splitlines(True)
279 279
 
280 280
         checker = pep8.Checker(filename=filename, lines=lines)
281 281
         # NOTE(sdague): the standard reporter has printing to stdout
@@ -571,12 +571,14 @@ class HackingTestCase(test.NoDBTestCase):
571 571
     def test_check_doubled_words(self):
572 572
         errors = [(1, 0, "N343")]
573 573
 
574
-        # Artificial break to stop pep8 detecting the test !
575
-        code = "This is the" + " the best comment"
574
+        # Explicit addition of line-ending here and below since this isn't a
575
+        # block comment and without it we trigger #1804062. Artificial break is
576
+        # necessary to stop flake8 detecting the test
577
+        code = "'This is the" + " the best comment'\n"
576 578
         self._assert_has_errors(code, checks.check_doubled_words,
577 579
                                 expected_errors=errors)
578 580
 
579
-        code = "This is the then best comment"
581
+        code = "'This is the then best comment'\n"
580 582
         self._assert_has_no_errors(code, checks.check_doubled_words)
581 583
 
582 584
     def test_dict_iteritems(self):

Loading…
Cancel
Save