11#
2- # Copyright 2014-2024 Ghent University
2+ # Copyright 2014-2025 Ghent University
33#
44# This file is part of EasyBuild,
55# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
@@ -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