diff --git a/nova/tests/unit/test_hacking.py b/nova/tests/unit/test_hacking.py index 82b822a7931a..c8dd1104a4b0 100644 --- a/nova/tests/unit/test_hacking.py +++ b/nova/tests/unit/test_hacking.py @@ -275,7 +275,7 @@ class HackingTestCase(test.NoDBTestCase): def _run_check(self, code, checker, filename=None): pep8.register_check(checker) - lines = textwrap.dedent(code).strip().splitlines(True) + lines = textwrap.dedent(code).lstrip().splitlines(True) checker = pep8.Checker(filename=filename, lines=lines) # NOTE(sdague): the standard reporter has printing to stdout @@ -571,12 +571,14 @@ class HackingTestCase(test.NoDBTestCase): def test_check_doubled_words(self): errors = [(1, 0, "N343")] - # Artificial break to stop pep8 detecting the test ! - code = "This is the" + " the best comment" + # Explicit addition of line-ending here and below since this isn't a + # block comment and without it we trigger #1804062. Artificial break is + # necessary to stop flake8 detecting the test + code = "'This is the" + " the best comment'\n" self._assert_has_errors(code, checks.check_doubled_words, expected_errors=errors) - code = "This is the then best comment" + code = "'This is the then best comment'\n" self._assert_has_no_errors(code, checks.check_doubled_words) def test_dict_iteritems(self):