def tearDown(self): # call _reset method clearing ModuleManager for unit testing, # otherwise the second, third, .. tests will use the instance created # in the first test instead of being properly initialized temp = gfdl.ModuleManager() temp.revert_state() temp._reset()
def test_module_unload(self): modMgr = gfdl.ModuleManager() modMgr.load(self.test_mod_name) mod_list = modMgr._list() self.assertIn(self.test_mod_name, mod_list) modMgr.unload(self.test_mod_name) mod_list = modMgr._list() self.assertNotIn(self.test_mod_name, mod_list)
def test_module_list(self): cmd = '{}/bin/modulecmd'.format(os.environ['MODULESHOME']) # module list writes to stderr, because all module user output does list1 = subprocess.check_output([cmd, 'python', 'list', '-t'], stderr=subprocess.STDOUT).splitlines() del list1[0] list1 = set([s.replace('(default)', '') for s in list1]) modMgr = gfdl.ModuleManager() list2 = set(modMgr._list()) self.assertEqual(list1, list2)
def setUp(self): _ = gfdl.ModuleManager()