From de139943d8272773b5f19ed824d687b0232b9ba3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 11 Mar 2023 09:03:03 +0100 Subject: Adding upstream version 0.19.1. Signed-off-by: Daniel Baumann --- gitlint-core/gitlint/tests/test_hooks.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'gitlint-core/gitlint/tests/test_hooks.py') diff --git a/gitlint-core/gitlint/tests/test_hooks.py b/gitlint-core/gitlint/tests/test_hooks.py index f92b148..7390f14 100644 --- a/gitlint-core/gitlint/tests/test_hooks.py +++ b/gitlint-core/gitlint/tests/test_hooks.py @@ -1,16 +1,15 @@ import os +from unittest.mock import ANY, mock_open, patch -from unittest.mock import patch, ANY, mock_open - -from gitlint.tests.base import BaseTestCase from gitlint.config import LintConfig from gitlint.hooks import ( - GitHookInstaller, - GitHookInstallerError, - COMMIT_MSG_HOOK_SRC_PATH, COMMIT_MSG_HOOK_DST_PATH, + COMMIT_MSG_HOOK_SRC_PATH, GITLINT_HOOK_IDENTIFIER, + GitHookInstaller, + GitHookInstallerError, ) +from gitlint.tests.base import BaseTestCase class HookTests(BaseTestCase): @@ -58,9 +57,10 @@ class HookTests(BaseTestCase): expected_msg = f"{lint_config.target} is not a git repository." with self.assertRaisesMessage(GitHookInstallerError, expected_msg): GitHookInstaller.install_commit_msg_hook(lint_config) - isdir.assert_called_with(git_hooks_dir.return_value) - path_exists.assert_not_called() - copy.assert_not_called() + + isdir.assert_called_with(git_hooks_dir.return_value) + path_exists.assert_not_called() + copy.assert_not_called() # mock that there is already a commit hook present isdir.return_value = True @@ -106,9 +106,10 @@ class HookTests(BaseTestCase): expected_msg = f"{lint_config.target} is not a git repository." with self.assertRaisesMessage(GitHookInstallerError, expected_msg): GitHookInstaller.uninstall_commit_msg_hook(lint_config) - isdir.assert_called_with(git_hooks_dir.return_value) - path_exists.assert_not_called() - remove.assert_not_called() + + isdir.assert_called_with(git_hooks_dir.return_value) + path_exists.assert_not_called() + remove.assert_not_called() # mock that there is no commit hook present isdir.return_value = True @@ -117,9 +118,10 @@ class HookTests(BaseTestCase): expected_msg = f"There is no commit-msg hook present in {expected_dst}." with self.assertRaisesMessage(GitHookInstallerError, expected_msg): GitHookInstaller.uninstall_commit_msg_hook(lint_config) - isdir.assert_called_with(git_hooks_dir.return_value) - path_exists.assert_called_once_with(expected_dst) - remove.assert_not_called() + + isdir.assert_called_with(git_hooks_dir.return_value) + path_exists.assert_called_once_with(expected_dst) + remove.assert_not_called() # mock that there is a different (=not gitlint) commit hook isdir.return_value = True -- cgit v1.2.3