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

This commit is contained in:
Zuul 2019-08-10 01:20:41 +00:00 committed by Gerrit Code Review
commit c04fc9e266
1 changed files with 6 additions and 4 deletions

View File

@ -275,7 +275,7 @@ class HackingTestCase(test.NoDBTestCase):
def _run_check(self, code, checker, filename=None): def _run_check(self, code, checker, filename=None):
pep8.register_check(checker) 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) checker = pep8.Checker(filename=filename, lines=lines)
# NOTE(sdague): the standard reporter has printing to stdout # NOTE(sdague): the standard reporter has printing to stdout
@ -571,12 +571,14 @@ class HackingTestCase(test.NoDBTestCase):
def test_check_doubled_words(self): def test_check_doubled_words(self):
errors = [(1, 0, "N343")] errors = [(1, 0, "N343")]
# Artificial break to stop pep8 detecting the test ! # Explicit addition of line-ending here and below since this isn't a
code = "This is the" + " the best comment" # 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, self._assert_has_errors(code, checks.check_doubled_words,
expected_errors=errors) 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) self._assert_has_no_errors(code, checks.check_doubled_words)
def test_dict_iteritems(self): def test_dict_iteritems(self):