Example #1
0
 def test_SetEnvironment_actions_E(self):
     setEnv = SetEnvironment(self._filename, "TEST_PROFILE_001")
     #with self.assertRaisesRegexp(KeyError, "module-list"):
     with self.assertRaises(KeyError):
         setEnv.actions = {
             'setenv': None,
             'unsetenv': None,
             'module-op': None
         }
Example #2
0
 def test_SetEnvironment_module_too_many_params(self):
     setEnv = SetEnvironment(self._filename, "TEST_PROFILE_001")
     setEnv.actions = {'setenv': None,
                       'unsetenv': None,
                       'module-op': [ ['load','a','b','c'] ],
                       'module-list': None
                       }
     #with self.assertRaisesRegexp(IndexError, 'Invalid number of parameters'):
     with self.assertRaises(IndexError):
         setEnv.pretty_print()
     #with self.assertRaisesRegexp(IndexError, 'Invalid number of parameters'):
     with self.assertRaises(IndexError):
         setEnv.apply()
Example #3
0
    def test_SetEnvironment_module_returns_NoneType(self):
        """
        Test handling of errors when the ModuleHelper.module() command has no
        return value (i.e., it returns a NoneType)

        This mimics the NoneType returned by the lmod based `module()` command
        which does not return anything. We now handle this through the addition
        of a wrapper for lmod modules that always returns a value but in case
        we ever have a module operation that returns NoneType we check the
        type. This test forces `apply()` to follow that exception branch.
        """
        setEnv = SetEnvironment(self._filename, "TEST_PROFILE_001")
        setEnv.actions = {'setenv': None,
                          'unsetenv': None,
                          'module-op': [ ['load','a','b'] ],
                          'module-list': None
                          }
        with self.assertRaises(TypeError):
            with patch('trilinosprhelpers.setenvironment.ModuleHelper.module', side_effect=mock_module_noreturn):
                setEnv.apply()
Example #4
0
 def test_SetEnvironment_actions_B(self):
     setEnv = SetEnvironment(self._filename, "TEST_PROFILE_001")
     #with self.assertRaisesRegexp(KeyError, "setenv"):
     with self.assertRaises(KeyError):
         setEnv.actions = {}
Example #5
0
 def test_SetEnvironment_actions_A(self):
     setEnv = SetEnvironment(self._filename, "TEST_PROFILE_001")
     #with self.assertRaisesRegexp(TypeError, "Invalid type provided"):
     with self.assertRaises(TypeError):
         setEnv.actions = "This should raise a TypeError"