summaryrefslogtreecommitdiffstats
path: root/gitlint-core/gitlint/tests/git/test_git_context.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-19 14:52:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-11-19 14:52:46 +0000
commita2aa51f5702b18016c25d943499941323952704d (patch)
tree7ee43f79639ee53903e7ca389e548974e1497c3a /gitlint-core/gitlint/tests/git/test_git_context.py
parentAdding upstream version 0.17.0. (diff)
downloadgitlint-a2aa51f5702b18016c25d943499941323952704d.tar.xz
gitlint-a2aa51f5702b18016c25d943499941323952704d.zip
Adding upstream version 0.18.0.upstream/0.18.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gitlint-core/gitlint/tests/git/test_git_context.py')
-rw-r--r--gitlint-core/gitlint/tests/git/test_git_context.py41
1 files changed, 15 insertions, 26 deletions
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)