Skip to content

Commit

Permalink
fix second part also
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoely86 committed Aug 20, 2020
1 parent f421b89 commit a02a31b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions test/easyblocks/init_easyblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def check_extra_options_format(extra_options):

def suite():
"""Return all easyblock initialisation tests."""
def make_inner_test(easyblock, **kwargs):
def innertest(self):
template_init_test(self, easyblock, **kwargs)
return innertest

# dynamically generate a separate test for each of the available easyblocks
easyblocks_path = get_paths_for("easyblocks")[0]
Expand All @@ -199,18 +203,16 @@ def suite():
# dynamically define new inner functions that can be added as class methods to InitTest
if os.path.basename(easyblock) == 'systemcompiler.py':
# use GCC as name when testing SystemCompiler easyblock
code = "def innertest(self): template_init_test(self, '%s', name='GCC', version='system')" % easyblock
innertest = make_inner_test(easyblock, name='GCC', version='system')
elif os.path.basename(easyblock) == 'systemmpi.py':
# use OpenMPI as name when testing SystemMPI easyblock
code = "def innertest(self): template_init_test(self, '%s', name='OpenMPI', version='system')" % easyblock
innertest = make_inner_test(easyblock, name='OpenMPI', version='system')
else:
code = "def innertest(self): template_init_test(self, '%s')" % easyblock
innertest = make_inner_test(easyblock)

exec(code, globals())

innertest.__doc__ = "Test for initialisation of easyblock %s" % easyblock # noqa
innertest.__name__ = "test_easyblock_%s" % '_'.join(easyblock.replace('.py', '').split('/')) # noqa
setattr(InitTest, innertest.__name__, innertest) # noqa
innertest.__doc__ = "Test for initialisation of easyblock %s" % easyblock
innertest.__name__ = "test_easyblock_%s" % '_'.join(easyblock.replace('.py', '').split('/'))
setattr(InitTest, innertest.__name__, innertest)

return TestLoader().loadTestsFromTestCase(InitTest)

Expand Down

0 comments on commit a02a31b

Please sign in to comment.