Example #1
0
    def test_get_latest_commit_command_not_found(self, sh):
        sh.git.side_effect = CommandNotFound("git")
        expected_msg = "'git' command not found. You need to install git to use gitlint on a local repository. " + \
                       "See https://git-scm.com/book/en/v2/Getting-Started-Installing-Git on how to install git."
        with self.assertRaisesRegex(GitNotInstalledError, expected_msg):
            GitContext.from_local_repository(u"fåke/path")

        # assert that commit message was read using git command
        sh.git.assert_called_once_with("log", "-1", "--pretty=%H", **self.expected_sh_special_args)
Example #2
0
    def test_get_latest_commit_command_not_found(self, sh):
        sh.git.log.side_effect = CommandNotFound("git")
        expected_msg = "'git' command not found. You need to install git to use gitlint on a local repository. " + \
                       "See https://git-scm.com/book/en/v2/Getting-Started-Installing-Git on how to install git."
        with self.assertRaisesRegexp(GitContextError, expected_msg):
            GitContext.from_local_repository("fake/path")

        # assert that commit message was read using git command
        sh.git.log.assert_called_once_with('-1',
                                           '--pretty=%B',
                                           _tty_out=False,
                                           _cwd="fake/path")
Example #3
0
 def test_git_error(self, sys, sh):
     """ Tests that the cli handles git errors properly """
     sys.stdin.isatty.return_value = True
     sh.git.side_effect = CommandNotFound("git")
     result = self.cli.invoke(cli.cli)
     self.assertEqual(result.exit_code, self.GIT_CONTEXT_ERROR_CODE)
Example #4
0
 def test_git_error(self, sys, sh):
     sys.stdin.isatty.return_value = True
     sh.git.log.side_effect = CommandNotFound("git")
     result = self.cli.invoke(cli.cli)
     self.assertEqual(result.exit_code, self.GIT_CONTEXT_ERROR_CODE)
Example #5
0
 def test_git_error(self, sh, _):
     """ Tests that the cli handles git errors properly """
     sh.git.side_effect = CommandNotFound("git")
     result = self.cli.invoke(cli.cli)
     self.assertEqual(result.exit_code, self.GIT_CONTEXT_ERROR_CODE)