mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 11:21:25 -07:00
Migrate basestring to a python3 compatible type (#17199)
This commit is contained in:
parent
a695e18615
commit
a22909c226
28 changed files with 137 additions and 101 deletions
|
@ -3,16 +3,18 @@ import mock
|
|||
import os
|
||||
import re
|
||||
|
||||
|
||||
from nose.tools import eq_
|
||||
try:
|
||||
from nose.tools import assert_raises_regexp
|
||||
except ImportError:
|
||||
from ansible.compat.six import string_types
|
||||
# Python < 2.7
|
||||
def assert_raises_regexp(expected, regexp, callable, *a, **kw):
|
||||
try:
|
||||
callable(*a, **kw)
|
||||
except expected as e:
|
||||
if isinstance(regexp, basestring):
|
||||
if isinstance(regexp, string_types):
|
||||
regexp = re.compile(regexp)
|
||||
if not regexp.search(str(e)):
|
||||
raise Exception('"%s" does not match "%s"' %
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue