def test_failingParsing(self, mock_print): mock_print.side_effect = FakeExit("raised") for (cmd, calls) in PARSER_ERRORS.items(): mock_print.mock_calls = [] with patch.object(sys, "argv", ["alibuild"] + shlex.split(cmd)): self.assertRaises(FakeExit, lambda: doParseArgs("ali")) self.assertEqual(mock_print.mock_calls, calls)
def test_failingParsing(self, mock_print): mock_print.side_effect = FakeExit("raised") for (cmd, calls) in PARSER_ERRORS.items(): mock_print.mock_calls = [] with patch.object(sys, "argv", ["alibuild"] + shlex.split(cmd)): self.assertRaises(FakeExit, lambda : doParseArgs("ali")) self.assertEqual(mock_print.mock_calls, calls)
def test_actionParsing(self, mock_commands): mock_commands.getstatusoutput.side_effect = lambda x : GETSTATUSOUTPUT_MOCKS[x] for (env, cmd, effects) in CORRECT_BEHAVIOR: (alibuild_helpers.args.DEFAULT_WORK_DIR, alibuild_helpers.args.DEFAULT_CHDIR) = env or ("sw", ".") with patch.object(sys, "argv", ["alibuild"] + shlex.split(cmd)): args, parser = doParseArgs("ali") args = vars(args) for k, v in effects: self.assertEqual(args[k], v)
def test_actionParsing(self, mock_commands): mock_commands.getstatusoutput.side_effect = lambda x : GETSTATUSOUTPUT_MOCKS[x] for (env, cmd, effects) in CORRECT_BEHAVIOR: env = env if env else ("sw", ".") alibuild_helpers.args.DEFAULT_WORK_DIR = env[0] alibuild_helpers.args.DEFAULT_CHDIR = env[1] with patch.object(sys, "argv", ["alibuild"] + shlex.split(cmd)): args, parser = doParseArgs("ali") args = vars(args) for k, v in effects: self.assertEqual(args[k], v) mock_commands.mock_calls