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_util.ModuleManager() temp.revert_state() temp._reset()
def test_module_unload(self): modMgr = gfdl_util.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_util.ModuleManager() list2 = set(modMgr._list()) self.assertEqual(list1, list2)
def tear_down(self): super(GfdlvirtualenvEnvironmentManager, self).tear_down() modMgr = gfdl_util.ModuleManager() modMgr.revert_state()
def deactivate_env_commands(self, env_name): modMgr = gfdl_util.ModuleManager() mod_list = modMgr.unload_commands(self._module_lookup[env_name]) return super(GfdlvirtualenvEnvironmentManager, \ self).deactivate_env_commands(env_name) + mod_list
def activate_env_commands(self, env_name): modMgr = gfdl_util.ModuleManager() mod_list = modMgr.load_commands(self._module_lookup[env_name]) return ['source $MODULESHOME/init/bash'] \ + mod_list \ + super(GfdlvirtualenvEnvironmentManager, self).activate_env_commands(env_name)
def create_environment(self, env_name): modMgr = gfdl_util.ModuleManager() modMgr.load(self._module_lookup[env_name]) super(GfdlvirtualenvEnvironmentManager, \ self).create_environment(env_name)
def __init__(self, log=_log): _ = gfdl_util.ModuleManager() super(GfdlvirtualenvEnvironmentManager, self).__init__(log=log)
def setup_fetch(self): modMgr = gfdl_util.ModuleManager() modMgr.load('gcp')
def setUp(self): _ = gfdl_util.ModuleManager()