diff options
author | Joris Roovers <joris.roovers@gmail.com> | 2019-08-16 13:50:09 +0200 |
---|---|---|
committer | Joris Roovers <joris.roovers@gmail.com> | 2019-08-16 13:50:09 +0200 |
commit | 2f192852929b0d7b6d48c8d2b4d36f825bd05aa6 (patch) | |
tree | e2404c29eb4480cd3225cbf9f362c20e65713d77 | |
parent | f66f23ff8f3b17d0843748748782a0fee24e0eeb (diff) |
Moved test expected strings to expected files
This declutters to unit and integration tests and makes the expected output
more easy to read.
30 files changed, 199 insertions, 188 deletions
@@ -22,6 +22,7 @@ var/ *.egg-info/ .installed.cfg *.egg +.pytest_cache # PyInstaller # Usually these files are written by a python script from a template diff --git a/gitlint/tests/base.py b/gitlint/tests/base.py index c78b140..e0695af 100644 --- a/gitlint/tests/base.py +++ b/gitlint/tests/base.py @@ -110,9 +110,14 @@ class BaseTestCase(unittest.TestCase): setattr(commit, attr, value) return commit - def assert_logged(self, lines): - """ Asserts that a certain list of messages has been logged """ - self.assertListEqual(self.logcapture.messages, lines) + def assert_logged(self, expected): + """ Asserts that the logs match an expected string or list. + This method knows how to compare a passed list of log lines as well as a newline concatenated string + of all loglines. """ + if isinstance(expected, list): + self.assertListEqual(self.logcapture.messages, expected) + else: + self.assertEqual("\n".join(self.logcapture.messages), expected) def assert_log_contains(self, line): """ Asserts that a certain line is in the logs """ diff --git a/gitlint/tests/expected/debug_configuration_output1 b/gitlint/tests/expected/debug_configuration_output1 deleted file mode 100644 index 33c7609..0000000 --- a/gitlint/tests/expected/debug_configuration_output1 +++ /dev/null @@ -1,43 +0,0 @@ -DEBUG: gitlint.cli Configuration -config-path: {config_path} -[GENERAL] -extra-path: None -contrib: [] -ignore: title-trailing-whitespace,B2 -ignore-merge-commits: False -ignore-fixup-commits: True -ignore-squash-commits: True -ignore-stdin: False -verbosity: 1 -debug: True -target: {target} -[RULES] - I1: ignore-by-title - ignore=all - regex=None - I2: ignore-by-body - ignore=all - regex=None - T1: title-max-length - line-length=20 - T2: title-trailing-whitespace - T6: title-leading-whitespace - T3: title-trailing-punctuation - T4: title-hard-tab - T5: title-must-not-contain-word - words=WIP,bögus - T7: title-match-regex - regex=.* - B1: body-max-line-length - line-length=30 - B5: body-min-length - min-length=20 - B6: body-is-missing - ignore-merge-commits=True - B2: body-trailing-whitespace - B3: body-hard-tab - B4: body-first-line-empty - B7: body-changed-file-mention - files= - M1: author-valid-email - regex=[^@ ]+@[^@ ]+\.[^@ ]+ diff --git a/gitlint/tests/expected/test_cli/test_debug_1 b/gitlint/tests/expected/test_cli/test_debug_1 new file mode 100644 index 0000000..67e2ecb --- /dev/null +++ b/gitlint/tests/expected/test_cli/test_debug_1 @@ -0,0 +1,72 @@ +DEBUG: gitlint.cli To report issues, please visit https://github.com/jorisroovers/gitlint/issues +DEBUG: gitlint.cli Platform: {platform} +DEBUG: gitlint.cli Python version: {python_version} +DEBUG: gitlint.cli Git version: git version 1.2.3 +DEBUG: gitlint.cli Gitlint version: {gitlint_version} +DEBUG: gitlint.cli GITLINT_USE_SH_LIB: {GITLINT_USE_SH_LIB} +DEBUG: gitlint.cli Configuration +config-path: {config_path} +[GENERAL] +extra-path: None +contrib: [] +ignore: title-trailing-whitespace,B2 +ignore-merge-commits: False +ignore-fixup-commits: True +ignore-squash-commits: True +ignore-stdin: False +verbosity: 1 +debug: True +target: {target} +[RULES] + I1: ignore-by-title + ignore=all + regex=None + I2: ignore-by-body + ignore=all + regex=None + T1: title-max-length + line-length=20 + T2: title-trailing-whitespace + T6: title-leading-whitespace + T3: title-trailing-punctuation + T4: title-hard-tab + T5: title-must-not-contain-word + words=WIP,bögus + T7: title-match-regex + regex=.* + B1: body-max-line-length + line-length=30 + B5: body-min-length + min-length=20 + B6: body-is-missing + ignore-merge-commits=True + B2: body-trailing-whitespace + B3: body-hard-tab + B4: body-first-line-empty + B7: body-changed-file-mention + files= + M1: author-valid-email + regex=[^@ ]+@[^@ ]+\.[^@ ]+ + +DEBUG: gitlint.cli No --msg-filename flag, no or empty data passed to stdin. Attempting to read from the local repo. +DEBUG: gitlint.lint Linting commit 6f29bf81a8322a04071bb794666e48c443a90360 +DEBUG: gitlint.lint Commit Object +Author: test åuthor1 <test-email1@föo.com> +Date: 2016-12-03 15:28:15+01:00 +commït-title1 + +commït-body1 +DEBUG: gitlint.lint Linting commit 25053ccec5e28e1bb8f7551fdbb5ab213ada2401 +DEBUG: gitlint.lint Commit Object +Author: test åuthor2 <test-email2@föo.com> +Date: 2016-12-04 15:28:15+01:00 +commït-title2. + +commït-body2 +DEBUG: gitlint.lint Linting commit 4da2656b0dadc76c7ee3fd0243a96cb64007f125 +DEBUG: gitlint.lint Commit Object +Author: test åuthor3 <test-email3@föo.com> +Date: 2016-12-05 15:28:15+01:00 +föo +bar +DEBUG: gitlint.cli Exit Code = 6
\ No newline at end of file diff --git a/gitlint/tests/expected/test_cli/test_input_stream_1 b/gitlint/tests/expected/test_cli/test_input_stream_1 new file mode 100644 index 0000000..4326729 --- /dev/null +++ b/gitlint/tests/expected/test_cli/test_input_stream_1 @@ -0,0 +1,3 @@ +1: T2 Title has trailing whitespace: "WIP: tïtle " +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: tïtle " +3: B6 Body message is missing diff --git a/gitlint/tests/expected/test_cli/test_lint_multiple_commits_1 b/gitlint/tests/expected/test_cli/test_lint_multiple_commits_1 new file mode 100644 index 0000000..be3288b --- /dev/null +++ b/gitlint/tests/expected/test_cli/test_lint_multiple_commits_1 @@ -0,0 +1,8 @@ +Commit 6f29bf81a8: +3: B5 Body message is too short (12<20): "commït-body1" + +Commit 25053ccec5: +3: B5 Body message is too short (12<20): "commït-body2" + +Commit 4da2656b0d: +3: B5 Body message is too short (12<20): "commït-body3" diff --git a/gitlint/tests/expected/test_cli/test_lint_multiple_commits_config_1 b/gitlint/tests/expected/test_cli/test_lint_multiple_commits_config_1 new file mode 100644 index 0000000..1bf0503 --- /dev/null +++ b/gitlint/tests/expected/test_cli/test_lint_multiple_commits_config_1 @@ -0,0 +1,6 @@ +Commit 6f29bf81a8: +3: B5 Body message is too short (12<20): "commït-body1" + +Commit 4da2656b0d: +1: T3 Title has trailing punctuation (.): "commït-title3." +3: B5 Body message is too short (12<20): "commït-body3" diff --git a/gitlint/tests/test_cli.py b/gitlint/tests/test_cli.py index b952b5c..823c798 100644 --- a/gitlint/tests/test_cli.py +++ b/gitlint/tests/test_cli.py @@ -104,13 +104,7 @@ class CLITests(BaseTestCase): with patch('gitlint.display.stderr', new=StringIO()) as stderr: result = self.cli.invoke(cli.cli, ["--commits", "foo...bar"]) - expected = (u"Commit 6f29bf81a8:\n" - u'3: B5 Body message is too short (12<20): "commït-body1"\n\n' - u"Commit 25053ccec5:\n" - u'3: B5 Body message is too short (12<20): "commït-body2"\n\n' - u"Commit 4da2656b0d:\n" - u'3: B5 Body message is too short (12<20): "commït-body3"\n') - self.assertEqual(stderr.getvalue(), expected) + self.assertEqual(stderr.getvalue(), self.get_expected("test_cli/test_lint_multiple_commits_1")) self.assertEqual(result.exit_code, 3) @patch('gitlint.cli.get_stdin_data', return_value=False) @@ -138,12 +132,7 @@ class CLITests(BaseTestCase): with patch('gitlint.display.stderr', new=StringIO()) as stderr: result = self.cli.invoke(cli.cli, ["--commits", "foo...bar"]) # We expect that the second commit has no failures because of 'gitlint-ignore: T3' in its commit msg body - expected = (u"Commit 6f29bf81a8:\n" - u'3: B5 Body message is too short (12<20): "commït-body1"\n\n' - u"Commit 4da2656b0d:\n" - u'1: T3 Title has trailing punctuation (.): "commït-title3."\n' - u'3: B5 Body message is too short (12<20): "commït-body3"\n') - self.assertEqual(stderr.getvalue(), expected) + self.assertEqual(stderr.getvalue(), self.get_expected("test_cli/test_lint_multiple_commits_config_1")) self.assertEqual(result.exit_code, 3) @patch('gitlint.cli.get_stdin_data', return_value=False) @@ -188,13 +177,9 @@ class CLITests(BaseTestCase): @patch('gitlint.cli.get_stdin_data', return_value=u'WIP: tïtle \n') def test_input_stream(self, _): """ Test for linting when a message is passed via stdin """ - expected_output = u"1: T2 Title has trailing whitespace: \"WIP: tïtle \"\n" + \ - u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP: tïtle \"\n" + \ - u"3: B6 Body message is missing\n" - with patch('gitlint.display.stderr', new=StringIO()) as stderr: result = self.cli.invoke(cli.cli) - self.assertEqual(stderr.getvalue(), expected_output) + self.assertEqual(stderr.getvalue(), self.get_expected("test_cli/test_input_stream_1")) self.assertEqual(result.exit_code, 3) self.assertEqual(result.output, "") @@ -302,29 +287,10 @@ class CLITests(BaseTestCase): self.assertEqual(stderr.getvalue(), expected) self.assertEqual(result.exit_code, 6) - # Make sure gitlint captured the correct logs - expected_logs = [u"DEBUG: gitlint.cli To report issues, please visit " + - u"https://github.com/jorisroovers/gitlint/issues", - u"DEBUG: gitlint.cli Platform: {0}".format(platform.platform()), - u"DEBUG: gitlint.cli Python version: {0}".format(sys.version), - u"DEBUG: gitlint.cli Git version: git version 1.2.3", - u"DEBUG: gitlint.cli Gitlint version: {0}".format(__version__), - u"DEBUG: gitlint.cli GITLINT_USE_SH_LIB: {0}".format(self.GITLINT_USE_SH_LIB), - self.get_expected('debug_configuration_output1', - {'config_path': config_path, 'target': os.path.realpath(os.getcwd())}), - u"DEBUG: gitlint.cli No --msg-filename flag, no or empty data passed to stdin. " + - u"Attempting to read from the local repo.", - u"DEBUG: gitlint.lint Linting commit 6f29bf81a8322a04071bb794666e48c443a90360", - u"DEBUG: gitlint.lint Commit Object\nAuthor: test åuthor1 <test-email1@föo.com>\n" + - u"Date: 2016-12-03 15:28:15+01:00\ncommït-title1\n\ncommït-body1", - u"DEBUG: gitlint.lint Linting commit 25053ccec5e28e1bb8f7551fdbb5ab213ada2401", - u"DEBUG: gitlint.lint Commit Object\nAuthor: test åuthor2 <test-email2@föo.com>\n" + - u"Date: 2016-12-04 15:28:15+01:00\ncommït-title2.\n\ncommït-body2", - u"DEBUG: gitlint.lint Linting commit 4da2656b0dadc76c7ee3fd0243a96cb64007f125", - u"DEBUG: gitlint.lint Commit Object\nAuthor: test åuthor3 <test-email3@föo.com>\n" + - u"Date: 2016-12-05 15:28:15+01:00\nföo\nbar", - u"DEBUG: gitlint.cli Exit Code = 6"] - + expected_kwargs = {'platform': platform.platform(), "python_version": sys.version, + 'gitlint_version': __version__, 'config_path': config_path, + 'GITLINT_USE_SH_LIB': self.GITLINT_USE_SH_LIB, 'target': os.path.realpath(os.getcwd())} + expected_logs = self.get_expected('test_cli/test_debug_1', expected_kwargs) self.assert_logged(expected_logs) @patch('gitlint.cli.get_stdin_data', return_value=u"Test tïtle\n") diff --git a/qa/expected/test_commits/test_ignore_commits_1 b/qa/expected/test_commits/test_ignore_commits_1 new file mode 100644 index 0000000..f9062c1 --- /dev/null +++ b/qa/expected/test_commits/test_ignore_commits_1 @@ -0,0 +1,11 @@ +Commit {commit_sha0}: +1: T3 Title has trailing punctuation (.): "Sïmple title4." + +Commit {commit_sha1}: +1: T5 Title contains the word 'WIP' (case-insensitive): "Sïmple WIP title3." + +Commit {commit_sha2}: +3: B5 Body message is too short (5<20): "Short" + +Commit {commit_sha3}: +1: T3 Title has trailing punctuation (.): "Sïmple title." diff --git a/qa/expected/test_commits/test_lint_head_1 b/qa/expected/test_commits/test_lint_head_1 new file mode 100644 index 0000000..d7ca594 --- /dev/null +++ b/qa/expected/test_commits/test_lint_head_1 @@ -0,0 +1,8 @@ +Commit {commit_sha0}: +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: Sïmple title" + +Commit {commit_sha1}: +3: B6 Body message is missing + +Commit {commit_sha2}: +1: T3 Title has trailing punctuation (.): "Sïmple title." diff --git a/qa/expected/test_commits/test_violations_1 b/qa/expected/test_commits/test_violations_1 new file mode 100644 index 0000000..6f3f9e2 --- /dev/null +++ b/qa/expected/test_commits/test_violations_1 @@ -0,0 +1,7 @@ +Commit {commit_sha2}: +1: T3 Title has trailing punctuation (.): "Sïmple title3." +3: B6 Body message is missing + +Commit {commit_sha1}: +1: T3 Title has trailing punctuation (.): "Sïmple title2." +3: B6 Body message is missing diff --git a/qa/expected/test_config/test_config_from_file_1 b/qa/expected/test_config/test_config_from_file_1 new file mode 100644 index 0000000..6fe434a --- /dev/null +++ b/qa/expected/test_config/test_config_from_file_1 @@ -0,0 +1,5 @@ +1: T1 Title exceeds max length (42>20) +1: T5 Title contains the word 'WIP' (case-insensitive) +1: T5 Title contains the word 'thåt' (case-insensitive) +2: B4 Second line is not empty +3: B1 Line exceeds max length (48>30) diff --git a/qa/expected/debug_output1 b/qa/expected/test_config/test_config_from_file_debug_1 index 05b9f4d..05b9f4d 100644 --- a/qa/expected/debug_output1 +++ b/qa/expected/test_config/test_config_from_file_debug_1 diff --git a/qa/expected/test_config/test_set_rule_option_1 b/qa/expected/test_config/test_set_rule_option_1 new file mode 100644 index 0000000..10b5e50 --- /dev/null +++ b/qa/expected/test_config/test_set_rule_option_1 @@ -0,0 +1,3 @@ +1: T1 Title exceeds max length (16>5): "This ïs a title." +1: T3 Title has trailing punctuation (.): "This ïs a title." +3: B6 Body message is missing diff --git a/qa/expected/test_config/test_verbosity_1 b/qa/expected/test_config/test_verbosity_1 new file mode 100644 index 0000000..0202072 --- /dev/null +++ b/qa/expected/test_config/test_verbosity_1 @@ -0,0 +1,3 @@ +1: T3 Title has trailing punctuation (.) +1: T5 Title contains the word 'WIP' (case-insensitive) +2: B4 Second line is not empty diff --git a/qa/expected/test_config/test_verbosity_2 b/qa/expected/test_config/test_verbosity_2 new file mode 100644 index 0000000..5a54082 --- /dev/null +++ b/qa/expected/test_config/test_verbosity_2 @@ -0,0 +1,3 @@ +1: T3 Title has trailing punctuation (.): "WIP: Thïs is a title." +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: Thïs is a title." +2: B4 Second line is not empty: "Contënt on the second line" diff --git a/qa/expected/test_gitlint/test_msg_filename_1 b/qa/expected/test_gitlint/test_msg_filename_1 new file mode 100644 index 0000000..d01b23b --- /dev/null +++ b/qa/expected/test_gitlint/test_msg_filename_1 @@ -0,0 +1,3 @@ +1: T3 Title has trailing punctuation (.): "WIP: msg-fïlename test." +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: msg-fïlename test." +3: B6 Body message is missing diff --git a/qa/expected/test_gitlint/test_msg_filename_no_tty_1 b/qa/expected/test_gitlint/test_msg_filename_no_tty_1 new file mode 100644 index 0000000..4785e28 --- /dev/null +++ b/qa/expected/test_gitlint/test_msg_filename_no_tty_1 @@ -0,0 +1,3 @@ +1: T3 Title has trailing punctuation (.): "WIP: msg-fïlename NO TTY test." +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: msg-fïlename NO TTY test." +3: B6 Body message is missing diff --git a/qa/expected/test_gitlint/test_violations_1 b/qa/expected/test_gitlint/test_violations_1 new file mode 100644 index 0000000..7e55eda --- /dev/null +++ b/qa/expected/test_gitlint/test_violations_1 @@ -0,0 +1,3 @@ +1: T3 Title has trailing punctuation (.): "WIP: This ïs a title." +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: This ïs a title." +2: B4 Second line is not empty: "Content on the sëcond line" diff --git a/qa/expected/test_stdin/test_stdin_file_1 b/qa/expected/test_stdin/test_stdin_file_1 new file mode 100644 index 0000000..ea7fad2 --- /dev/null +++ b/qa/expected/test_stdin/test_stdin_file_1 @@ -0,0 +1,3 @@ +1: T3 Title has trailing punctuation (.): "WIP: STDIN ïs a file test." +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: STDIN ïs a file test." +3: B6 Body message is missing diff --git a/qa/expected/test_stdin/test_stdin_pipe_1 b/qa/expected/test_stdin/test_stdin_pipe_1 new file mode 100644 index 0000000..8714533 --- /dev/null +++ b/qa/expected/test_stdin/test_stdin_pipe_1 @@ -0,0 +1,3 @@ +1: T3 Title has trailing punctuation (.): "WIP: Pïpe test." +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: Pïpe test." +3: B6 Body message is missing diff --git a/qa/expected/test_stdin/test_stdin_pipe_empty_1 b/qa/expected/test_stdin/test_stdin_pipe_empty_1 new file mode 100644 index 0000000..7e55eda --- /dev/null +++ b/qa/expected/test_stdin/test_stdin_pipe_empty_1 @@ -0,0 +1,3 @@ +1: T3 Title has trailing punctuation (.): "WIP: This ïs a title." +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: This ïs a title." +2: B4 Second line is not empty: "Content on the sëcond line" diff --git a/qa/expected/test_user_defined/test_user_defined_rules_1 b/qa/expected/test_user_defined/test_user_defined_rules_1 new file mode 100644 index 0000000..babc6f6 --- /dev/null +++ b/qa/expected/test_user_defined/test_user_defined_rules_1 @@ -0,0 +1,4 @@ +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: Thi$ is å title" +1: UC2 Body does not contain a 'Signed-Off-By' line +1: UL1 Title contains the special character '$': "WIP: Thi$ is å title" +2: B4 Second line is not empty: "Content on the second line" diff --git a/qa/expected/test_user_defined/test_user_defined_rules_with_config_1 b/qa/expected/test_user_defined/test_user_defined_rules_with_config_1 new file mode 100644 index 0000000..82ef332 --- /dev/null +++ b/qa/expected/test_user_defined/test_user_defined_rules_with_config_1 @@ -0,0 +1,5 @@ +1: T5 Title contains the word 'WIP' (case-insensitive): "WIP: Thi$ is å title" +1: UC1 Body contains too many lines (2 > 1) +1: UC2 Body does not contain a 'Signed-Off-By' line +1: UL1 Title contains the special character '$': "WIP: Thi$ is å title" +2: B4 Second line is not empty: "Content on the second line" diff --git a/qa/test_commits.py b/qa/test_commits.py index 859d70a..be6b35f 100644 --- a/qa/test_commits.py +++ b/qa/test_commits.py @@ -31,16 +31,10 @@ class CommitsTests(BaseTestCase): commit_sha2 = self.get_last_commit_hash()[:10] output = gitlint("--commits", "test-branch-commits-violations-base...test-branch-commits-violations", _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[4]) - expected = (u"Commit {0}:\n".format(commit_sha2) + - u"1: T3 Title has trailing punctuation (.): \"Sïmple title3.\"\n" + - u"3: B6 Body message is missing\n" - "\n" - u"Commit {0}:\n".format(commit_sha1) + - u"1: T3 Title has trailing punctuation (.): \"Sïmple title2.\"\n" - u"3: B6 Body message is missing\n") self.assertEqual(output.exit_code, 4) - self.assertEqualStdout(output, expected) + expected_kwargs = {'commit_sha1': commit_sha1, 'commit_sha2': commit_sha2} + self.assertEqualStdout(output, self.get_expected("test_commits/test_violations_1", expected_kwargs)) def test_lint_single_commit(self): self._create_simple_commit(u"Sïmple title.\n") @@ -63,16 +57,10 @@ class CommitsTests(BaseTestCase): output = gitlint("--commits", "HEAD", _cwd=tmp_git_repo, _tty_in=True, _ok_code=[3]) revlist = git("rev-list", "HEAD", _tty_in=True, _cwd=tmp_git_repo).split() - expected = ( - u"Commit {0}:\n".format(revlist[0][:10]) + - u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP: Sïmple title\"\n\n" + - u"Commit {0}:\n".format(revlist[1][:10]) + - u"3: B6 Body message is missing\n\n" + - u"Commit {0}:\n".format(revlist[2][:10]) + - u"1: T3 Title has trailing punctuation (.): \"Sïmple title.\"\n" - ) + expected_kwargs = {"commit_sha0": revlist[0][:10], "commit_sha1": revlist[1][:10], + "commit_sha2": revlist[2][:10]} - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_commits/test_lint_head_1", expected_kwargs)) def test_ignore_commits(self): """ Tests multiple commits of which some rules get igonored because of ignore-* rules """ @@ -91,15 +79,6 @@ class CommitsTests(BaseTestCase): config_path = self.get_sample_path("config/ignore-release-commits") output = gitlint("--commits", "HEAD", "--config", config_path, _cwd=tmp_git_repo, _tty_in=True, _ok_code=[4]) - expected = ( - u"Commit {0}:\n".format(revlist[0][:10]) + - u"1: T3 Title has trailing punctuation (.): \"Sïmple title4.\"\n\n" + - u"Commit {0}:\n".format(revlist[1][:10]) + - u"1: T5 Title contains the word 'WIP' (case-insensitive): \"Sïmple WIP title3.\"\n\n" + - u"Commit {0}:\n".format(revlist[2][:10]) + - u"3: B5 Body message is too short (5<20): \"Short\"\n\n" + - u"Commit {0}:\n".format(revlist[3][:10]) + - u"1: T3 Title has trailing punctuation (.): \"Sïmple title.\"\n" - ) - - self.assertEqualStdout(output, expected) + expected_kwargs = {"commit_sha0": revlist[0][:10], "commit_sha1": revlist[1][:10], + "commit_sha2": revlist[2][:10], "commit_sha3": revlist[3][:10]} + self.assertEqualStdout(output, self.get_expected("test_commits/test_ignore_commits_1", expected_kwargs)) diff --git a/qa/test_config.py b/qa/test_config.py index a346324..83800e4 100644 --- a/qa/test_config.py +++ b/qa/test_config.py @@ -32,16 +32,10 @@ class ConfigTests(BaseTestCase): self.assertEqualStdout(output, expected) output = gitlint("-vv", _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[3]) - expected = u"1: T3 Title has trailing punctuation (.)\n" + \ - u"1: T5 Title contains the word 'WIP' (case-insensitive)\n" + \ - u"2: B4 Second line is not empty\n" - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_config/test_verbosity_1")) output = gitlint("-vvv", _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[3]) - expected = u"1: T3 Title has trailing punctuation (.): \"WIP: Thïs is a title.\"\n" + \ - u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP: Thïs is a title.\"\n" + \ - u"2: B4 Second line is not empty: \"Contënt on the second line\"\n" - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_config/test_verbosity_2")) # test silent mode output = gitlint("--silent", _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[3]) @@ -50,10 +44,7 @@ class ConfigTests(BaseTestCase): def test_set_rule_option(self): self._create_simple_commit(u"This ïs a title.") output = gitlint("-c", "title-max-length.line-length=5", _tty_in=True, _cwd=self.tmp_git_repo, _ok_code=[3]) - expected = u"1: T1 Title exceeds max length (16>5): \"This ïs a title.\"\n" + \ - u"1: T3 Title has trailing punctuation (.): \"This ïs a title.\"\n" + \ - "3: B6 Body message is missing\n" - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_config/test_set_rule_option_1")) def test_config_from_file(self): commit_msg = u"WIP: Thïs is a title thåt is a bit longer.\nContent on the second line\n" + \ @@ -61,14 +52,7 @@ class ConfigTests(BaseTestCase): self._create_simple_commit(commit_msg) config_path = self.get_sample_path("config/gitlintconfig") output = gitlint("--config", config_path, _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[5]) - - expected = "1: T1 Title exceeds max length (42>20)\n" + \ - "1: T5 Title contains the word 'WIP' (case-insensitive)\n" + \ - u"1: T5 Title contains the word 'thåt' (case-insensitive)\n" + \ - "2: B4 Second line is not empty\n" + \ - "3: B1 Line exceeds max length (48>30)\n" - - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_config/test_config_from_file_1")) def test_config_from_file_debug(self): commit_msg = u"WIP: Thïs is a title thåt is a bit longer.\nContent on the second line\n" + \ @@ -83,11 +67,9 @@ class ConfigTests(BaseTestCase): expected_gitlint_version = gitlint("--version").replace("gitlint, version ", "").replace("\n", "") expected_git_version = git("--version").replace("\n", "") - expected = self.get_expected('debug_output1', {'platform': platform.platform(), 'python_version': sys.version, - 'git_version': expected_git_version, - 'gitlint_version': expected_gitlint_version, - 'GITLINT_USE_SH_LIB': self.GITLINT_USE_SH_LIB, - 'config_path': config_path, 'target': self.tmp_git_repo, - 'commit_sha': commit_sha, 'commit_date': expected_date}) + expected_kwargs = {'platform': platform.platform(), 'python_version': sys.version, + 'git_version': expected_git_version, 'gitlint_version': expected_gitlint_version, + 'GITLINT_USE_SH_LIB': self.GITLINT_USE_SH_LIB, 'config_path': config_path, + 'target': self.tmp_git_repo, 'commit_sha': commit_sha, 'commit_date': expected_date} - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_config/test_config_from_file_debug_1", expected_kwargs)) diff --git a/qa/test_gitlint.py b/qa/test_gitlint.py index 29d4cbb..3574b24 100644 --- a/qa/test_gitlint.py +++ b/qa/test_gitlint.py @@ -119,22 +119,12 @@ class IntegrationTests(BaseTestCase): commit_msg = u"WIP: This ïs a title.\nContent on the sëcond line" self._create_simple_commit(commit_msg) output = gitlint(_cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[3]) - - expected = u"1: T3 Title has trailing punctuation (.): \"WIP: This ïs a title.\"\n" + \ - u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP: This ïs a title.\"\n" + \ - u"2: B4 Second line is not empty: \"Content on the sëcond line\"\n" - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_gitlint/test_violations_1")) def test_msg_filename(self): tmp_commit_msg_file = self.create_tmpfile("WIP: msg-fïlename test.") - output = gitlint("--msg-filename", tmp_commit_msg_file, _tty_in=True, _ok_code=[3]) - - expected = u"1: T3 Title has trailing punctuation (.): \"WIP: msg-fïlename test.\"\n" + \ - u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP: msg-fïlename test.\"\n" + \ - u"3: B6 Body message is missing\n" - - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_gitlint/test_msg_filename_1")) def test_msg_filename_no_tty(self): """ Make sure --msg-filename option also works with no TTY attached """ @@ -148,8 +138,4 @@ class IntegrationTests(BaseTestCase): output = gitlint("--msg-filename", tmp_commit_msg_file, _in=" ", _tty_in=False, _err_to_out=True, _ok_code=[3]) - expected = u"1: T3 Title has trailing punctuation (.): \"WIP: msg-fïlename NO TTY test.\"\n" + \ - u"1: T5 Title contains the word 'WIP' (case-insensitive): \"WIP: msg-fïlename NO TTY test.\"\n" + \ - u"3: B6 Body message is missing\n" - - self.assertEqualStdout(output, expected) + self.assertEqualStdout(output, self.get_expected("test_gitlint/test_msg_filename_no_tty_1")) diff --git a/qa/test_stdin.py b/qa/test_stdin.py index a1ce26a..973741c 100644 --- a/qa/test_stdin.py +++ b/qa/test_stdin.py @@ -18,12 +18,7 @@ class StdInTe |