mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Make assert_error compatible with Python 3.6
The re.Pattern class was introduced in Python 3.7. Use duck-typing to distinguish between str and re pattern object. Fixes: https://pagure.io/freeipa/issue/8179 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Sergey Orlov <sorlov@redhat.com>
This commit is contained in:
parent
e107b8e4fe
commit
10b62ad6bc
@ -1615,7 +1615,7 @@ def assert_error(result, pattern, returncode=None):
|
||||
``pattern`` may be a ``str`` or a ``re.Pattern`` (regular expression).
|
||||
|
||||
"""
|
||||
if isinstance(pattern, re.Pattern):
|
||||
if hasattr(pattern, "search"): # re pattern
|
||||
assert pattern.search(result.stderr_text), \
|
||||
f"pattern {pattern} not found in stderr {result.stderr_text!r}"
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user