selftests/unit/test_safeloader.py: do not rely on assertRegex* methods
The prevailing coding style of Avocado (unittest.TestCase) tests is to
use the specialized assert methods, such as assertNotRegexpMatches.
Unfortunately, the regular expression related assertion methods have
been through a messy renaming. In theory, assertNotRegexpMatches and
assertRegexpMatches should be available in Python 3.0 and 3.1, but not
in Python >= 3.2, where it got renamed to assertRegex and
assertNotRegex.
In practice, in my system with Python 3.6.3, I see:
>>> unittest.TestCase.assertNotRegexpMatches
<function TestCase._deprecate.<locals>.deprecated_func at 0x7f3b85b709d8>
But in Travis, with Python 3.4, it's not available:
ERROR: test_directives_regex (selftests.unit.test_safeloader.DocstringDirectives)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/avocado-framework/avocado/selftests/unit/test_safeloader.py", line 135, in test_directives_regex
self.assertNotRegexpMatches(directive, safeloader.DOCSTRING_DIRECTIVE_RE)
AttributeError: 'DocstringDirectives' object has no attribute 'assertNotRegexpMatches'
Let's simplify things and just use a regex match and check for its
result.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
Showing
想要评论请 注册 或 登录