Skip to content

Commit

Permalink
Merge pull request #4756 from Flamefire/superflous-is-string
Browse files Browse the repository at this point in the history
Remove superflous `is_string` method
  • Loading branch information
branfosj authored Feb 6, 2025
2 parents df528c6 + 85a6629 commit 79dfbde
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions easybuild/base/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ class TestCase(OrigTestCase):
ASSERT_MAX_DIFF = 100
DIFF_OFFSET = 5 # lines of text around changes

def is_string(self, x):
"""test if the variable x is a string)"""
try:
return isinstance(x, str)
except NameError:
return isinstance(x, str)

# pylint: disable=arguments-differ
def assertEqual(self, a, b, msg=None):
"""Make assertEqual always print useful messages"""
Expand All @@ -95,11 +88,11 @@ def assertEqual(self, a, b, msg=None):
else:
msg = "%s: %s" % (msg, e)

if self.is_string(a):
if isinstance(a, str):
txta = a
else:
txta = pprint.pformat(a)
if self.is_string(b):
if isinstance(b, str):
txtb = b
else:
txtb = pprint.pformat(b)
Expand Down Expand Up @@ -167,7 +160,7 @@ def assertErrorRegex(self, error, regex, call, *args, **kwargs):
self.fail("Expected errors with %s(%s) call should occur" % (call.__name__, str_args))
except error as err:
msg = self.convert_exception_to_str(err)
if self.is_string(regex):
if isinstance(regex, str):
regex = re.compile(regex)
self.assertTrue(regex.search(msg), "Pattern '%s' is found in '%s'" % (regex.pattern, msg))

Expand Down

0 comments on commit 79dfbde

Please sign in to comment.