args = [ '--software-name=nosuchsoftware', '--robot=.', '--debug', ] myerr = None try: main((args, self.logfile, False)) except (SystemExit, Exception), err: myerr = err outtxt = read_file(self.logfile) # error message when template is not found error_msg1 = "ERROR .* No easyconfig files found for software nosuchsoftware, and no templates available. I'm all out of ideas." # error message when template is found error_msg2 = "ERROR .* Unable to find an easyconfig for the given specifications" msg = "Error message when eb can't find software with specified name (myerr: %s, outtxt: %s)" % ( myerr, outtxt) self.assertTrue( re.search(error_msg1, outtxt) or re.search(error_msg2, outtxt), msg) def suite(): """ returns all the testcases in this module """ return TestLoader().loadTestsFromTestCase(CommandLineOptionsTest) if __name__ == '__main__': unittestmain()
# initialize Lmod modules tool, pass full path to 'lmod' via $LMOD_CMD os.environ['LMOD_CMD'] = lmod_abspath lmod = Lmod(testing=True) # obtain list of availabe modules, should be non-empty self.assertTrue(lmod.available(), "List of available modules obtained using Lmod is non-empty") # test updating local spider cache (but don't actually update the local cache file!) self.assertTrue(lmod.update(), "Updated local Lmod spider cache is non-empty") def tearDown(self): """Testcase cleanup.""" super(ModulesToolTest, self).tearDown() # restore 'module' function if self.orig_module is not None: os.environ['module'] = self.orig_module else: if 'module' in os.environ: del os.environ['module'] def suite(): """ returns all the testcases in this module """ return TestLoader().loadTestsFromTestCase(ModulesToolTest) if __name__ == '__main__': unittestmain()