Handle py38 unit test changes

Our py38 unit tests have been failing due to some changes in our hacking
test results. The column offset being returned by the checks changes
with py38, so in order to maintain compatibility with py38 and earlier
versions, this changes the checks for column number to mock.ANY. We
don't really care about the column anyway, just whether things
appropriately return an error.

Change-Id: Iff70244a1c94da8aed4f8e42bb45362ada6c901f
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-04-14 10:29:47 -05:00
parent a20d01550b
commit 8716c55272
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
1 changed files with 11 additions and 5 deletions

View File

@ -148,9 +148,11 @@ class HackingTestCase(test.TestCase):
LOG.{0}("Volume %s caught fire and is at %d degrees C and "
"climbing.", ('volume1', 500))
"""
# We don't assert on specific column numbers since there is a small
# change in calculation between <py38 and >=py38
for method in checker.LOG_METHODS:
self._assert_has_errors(code.format(method), checker,
expected_errors=[(4, 21, 'C310')])
expected_errors=[(4, mock.ANY, 'C310')])
code = """
import logging
@ -158,8 +160,10 @@ class HackingTestCase(test.TestCase):
LOG.log(logging.DEBUG, "Volume %s caught fire and is at %d"
" degrees C and climbing.", ('volume1', 500))
"""
# We don't assert on specific column numbers since there is a small
# change in calculation between <py38 and >=py38
self._assert_has_errors(code, checker,
expected_errors=[(4, 37, 'C310')])
expected_errors=[(4, mock.ANY, 'C310')])
def test_opt_type_registration_args(self):
checker = checks.CheckOptRegistrationArgs
@ -178,11 +182,13 @@ class HackingTestCase(test.TestCase):
CONF.register_opts(lonely_opt)
CONF.register_opt((an_opt, another_opt))
"""
# We don't assert on specific column numbers since there is a small
# change in calculation between <py38 and >=py38
self._assert_has_errors(code, checker,
expected_errors=[(1, 18, 'C311'),
(2, 19, 'C311'),
(3, 19, 'C311'),
(4, 19, 'C311')])
(2, mock.ANY, 'C311'),
(3, mock.ANY, 'C311'),
(4, mock.ANY, 'C311')])
code = """
CONF.register_opt(single_opt)