diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-25 13:26:08 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-25 13:26:08 +0000 |
commit | 3313b4f9c3c5d6a579588e77068ca3ae3edffe2b (patch) | |
tree | 81fccb2a4db79b0de9b0d64701581add3a9a1d21 /gitlint/tests/config/test_config_precedence.py | |
parent | Adding upstream version 0.14.0. (diff) | |
download | gitlint-3313b4f9c3c5d6a579588e77068ca3ae3edffe2b.tar.xz gitlint-3313b4f9c3c5d6a579588e77068ca3ae3edffe2b.zip |
Adding upstream version 0.15.0.upstream/0.15.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gitlint/tests/config/test_config_precedence.py')
-rw-r--r-- | gitlint/tests/config/test_config_precedence.py | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/gitlint/tests/config/test_config_precedence.py b/gitlint/tests/config/test_config_precedence.py index a0eeccd..aa4de88 100644 --- a/gitlint/tests/config/test_config_precedence.py +++ b/gitlint/tests/config/test_config_precedence.py @@ -1,20 +1,10 @@ # -*- coding: utf-8 -*- -try: - # python 2.x - from StringIO import StringIO -except ImportError: - # python 3.x - from io import StringIO +from io import StringIO from click.testing import CliRunner -try: - # python 2.x - from mock import patch -except ImportError: - # python 3.x - from unittest.mock import patch # pylint: disable=no-name-in-module, import-error +from unittest.mock import patch from gitlint.tests.base import BaseTestCase from gitlint import cli @@ -25,7 +15,7 @@ class LintConfigPrecedenceTests(BaseTestCase): def setUp(self): self.cli = CliRunner() - @patch('gitlint.cli.get_stdin_data', return_value=u"WIP:fö\n\nThis is å test message\n") + @patch('gitlint.cli.get_stdin_data', return_value="WIP:fö\n\nThis is å test message\n") def test_config_precedence(self, _): # TODO(jroovers): this test really only test verbosity, we need to do some refactoring to gitlint.cli # to more easily test everything @@ -41,14 +31,14 @@ class LintConfigPrecedenceTests(BaseTestCase): with patch('gitlint.display.stderr', new=StringIO()) as stderr: result = self.cli.invoke(cli.cli, ["-vvv", "-c", "general.verbosity=2", "--config", config_path]) self.assertEqual(result.output, "") - self.assertEqual(stderr.getvalue(), u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP:fö\"\n") + self.assertEqual(stderr.getvalue(), "1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP:fö\"\n") # 2. environment variables with patch('gitlint.display.stderr', new=StringIO()) as stderr: result = self.cli.invoke(cli.cli, ["-c", "general.verbosity=2", "--config", config_path], env={"GITLINT_VERBOSITY": "3"}) self.assertEqual(result.output, "") - self.assertEqual(stderr.getvalue(), u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP:fö\"\n") + self.assertEqual(stderr.getvalue(), "1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP:fö\"\n") # 3. commandline -c flags with patch('gitlint.display.stderr', new=StringIO()) as stderr: @@ -66,9 +56,9 @@ class LintConfigPrecedenceTests(BaseTestCase): with patch('gitlint.display.stderr', new=StringIO()) as stderr: result = self.cli.invoke(cli.cli) self.assertEqual(result.output, "") - self.assertEqual(stderr.getvalue(), u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP:fö\"\n") + self.assertEqual(stderr.getvalue(), "1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP:fö\"\n") - @patch('gitlint.cli.get_stdin_data', return_value=u"WIP: This is å test") + @patch('gitlint.cli.get_stdin_data', return_value="WIP: This is å test") def test_ignore_precedence(self, get_stdin_data): with patch('gitlint.display.stderr', new=StringIO()) as stderr: # --ignore takes precedence over -c general.ignore @@ -77,11 +67,11 @@ class LintConfigPrecedenceTests(BaseTestCase): self.assertEqual(result.exit_code, 1) # We still expect the T5 violation, but no B6 violation as --ignore overwrites -c general.ignore self.assertEqual(stderr.getvalue(), - u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP: This is å test\"\n") + "1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP: This is å test\"\n") # test that we can also still configure a rule that is first ignored but then not with patch('gitlint.display.stderr', new=StringIO()) as stderr: - get_stdin_data.return_value = u"This is å test" + get_stdin_data.return_value = "This is å test" # --ignore takes precedence over -c general.ignore result = self.cli.invoke(cli.cli, ["-c", "general.ignore=title-max-length", "-c", "title-max-length.line-length=5", @@ -91,7 +81,7 @@ class LintConfigPrecedenceTests(BaseTestCase): # We still expect the T1 violation with custom config, # but no B6 violation as --ignore overwrites -c general.ignore - self.assertEqual(stderr.getvalue(), u"1: T1 Title exceeds max length (14>5): \"This is å test\"\n") + self.assertEqual(stderr.getvalue(), "1: T1 Title exceeds max length (14>5): \"This is å test\"\n") def test_general_option_after_rule_option(self): # We used to have a bug where we didn't process general options before setting specific options, this would |