Skip to content

Commit 79dfbde

Browse files
authored
Merge pull request #4756 from Flamefire/superflous-is-string
Remove superflous `is_string` method
2 parents df528c6 + 85a6629 commit 79dfbde

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

easybuild/base/testing.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ class TestCase(OrigTestCase):
7676
ASSERT_MAX_DIFF = 100
7777
DIFF_OFFSET = 5 # lines of text around changes
7878

79-
def is_string(self, x):
80-
"""test if the variable x is a string)"""
81-
try:
82-
return isinstance(x, str)
83-
except NameError:
84-
return isinstance(x, str)
85-
8679
# pylint: disable=arguments-differ
8780
def assertEqual(self, a, b, msg=None):
8881
"""Make assertEqual always print useful messages"""
@@ -95,11 +88,11 @@ def assertEqual(self, a, b, msg=None):
9588
else:
9689
msg = "%s: %s" % (msg, e)
9790

98-
if self.is_string(a):
91+
if isinstance(a, str):
9992
txta = a
10093
else:
10194
txta = pprint.pformat(a)
102-
if self.is_string(b):
95+
if isinstance(b, str):
10396
txtb = b
10497
else:
10598
txtb = pprint.pformat(b)
@@ -167,7 +160,7 @@ def assertErrorRegex(self, error, regex, call, *args, **kwargs):
167160
self.fail("Expected errors with %s(%s) call should occur" % (call.__name__, str_args))
168161
except error as err:
169162
msg = self.convert_exception_to_str(err)
170-
if self.is_string(regex):
163+
if isinstance(regex, str):
171164
regex = re.compile(regex)
172165
self.assertTrue(regex.search(msg), "Pattern '%s' is found in '%s'" % (regex.pattern, msg))
173166

0 commit comments

Comments
 (0)