From a2aa51f5702b18016c25d943499941323952704d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 19 Nov 2022 15:52:46 +0100 Subject: Adding upstream version 0.18.0. Signed-off-by: Daniel Baumann --- gitlint-core/gitlint/tests/git/test_git_context.py | 41 ++++++++-------------- 1 file changed, 15 insertions(+), 26 deletions(-) (limited to 'gitlint-core/gitlint/tests/git/test_git_context.py') diff --git a/gitlint-core/gitlint/tests/git/test_git_context.py b/gitlint-core/gitlint/tests/git/test_git_context.py index bb05236..3dcbe4a 100644 --- a/gitlint-core/gitlint/tests/git/test_git_context.py +++ b/gitlint-core/gitlint/tests/git/test_git_context.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from unittest.mock import patch, call from gitlint.tests.base import BaseTestCase @@ -7,24 +5,16 @@ from gitlint.git import GitContext class GitContextTests(BaseTestCase): - # Expected special_args passed to 'sh' - expected_sh_special_args = { - '_tty_out': False, - '_cwd': "fåke/path" - } + expected_sh_special_args = {"_tty_out": False, "_cwd": "fåke/path"} - @patch('gitlint.git.sh') + @patch("gitlint.git.sh") def test_gitcontext(self, sh): - - sh.git.side_effect = [ - "#", # git config --get core.commentchar - "\nfoöbar\n" - ] + sh.git.side_effect = ["#", "\nfoöbar\n"] # git config --get core.commentchar expected_calls = [ call("config", "--get", "core.commentchar", _ok_code=[0, 1], **self.expected_sh_special_args), - call("rev-parse", "--abbrev-ref", "HEAD", **self.expected_sh_special_args) + call("rev-parse", "--abbrev-ref", "HEAD", **self.expected_sh_special_args), ] context = GitContext("fåke/path") @@ -38,12 +28,11 @@ class GitContextTests(BaseTestCase): self.assertEqual(context.current_branch, "foöbar") self.assertEqual(sh.git.mock_calls, expected_calls) - @patch('gitlint.git.sh') + @patch("gitlint.git.sh") def test_gitcontext_equality(self, sh): - sh.git.side_effect = [ - "û\n", # context1: git config --get core.commentchar - "û\n", # context2: git config --get core.commentchar + "û\n", # context1: git config --get core.commentchar + "û\n", # context2: git config --get core.commentchar "my-brånch\n", # context1: git rev-parse --abbrev-ref HEAD "my-brånch\n", # context2: git rev-parse --abbrev-ref HEAD ] @@ -68,17 +57,17 @@ class GitContextTests(BaseTestCase): # Different comment_char context3 = GitContext("fåke/path") context3.commits = ["fōo", "bår"] - sh.git.side_effect = ([ - "ç\n", # context3: git config --get core.commentchar - "my-brånch\n" # context3: git rev-parse --abbrev-ref HEAD - ]) + sh.git.side_effect = [ + "ç\n", # context3: git config --get core.commentchar + "my-brånch\n", # context3: git rev-parse --abbrev-ref HEAD + ] self.assertNotEqual(context1, context3) # Different current_branch context4 = GitContext("fåke/path") context4.commits = ["fōo", "bår"] - sh.git.side_effect = ([ - "û\n", # context4: git config --get core.commentchar - "different-brånch\n" # context4: git rev-parse --abbrev-ref HEAD - ]) + sh.git.side_effect = [ + "û\n", # context4: git config --get core.commentchar + "different-brånch\n", # context4: git rev-parse --abbrev-ref HEAD + ] self.assertNotEqual(context1, context4) -- cgit v1.2.3