diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-25 13:26:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-01-25 13:26:35 +0000 |
commit | 4fee3e091a8d79a40f70ff9c1f87b29b9340049a (patch) | |
tree | 465ad9629a8ee56548bd6c51c3fc710907564911 /gitlint/tests/rules/test_configuration_rules.py | |
parent | Releasing debian version 0.14.0-1. (diff) | |
download | gitlint-4fee3e091a8d79a40f70ff9c1f87b29b9340049a.tar.xz gitlint-4fee3e091a8d79a40f70ff9c1f87b29b9340049a.zip |
Merging upstream version 0.15.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gitlint/tests/rules/test_configuration_rules.py')
-rw-r--r-- | gitlint/tests/rules/test_configuration_rules.py | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/gitlint/tests/rules/test_configuration_rules.py b/gitlint/tests/rules/test_configuration_rules.py index 121cb3a..479d9c2 100644 --- a/gitlint/tests/rules/test_configuration_rules.py +++ b/gitlint/tests/rules/test_configuration_rules.py @@ -6,7 +6,7 @@ from gitlint.config import LintConfig class ConfigurationRuleTests(BaseTestCase): def test_ignore_by_title(self): - commit = self.gitcommit(u"Releäse\n\nThis is the secōnd body line") + commit = self.gitcommit("Releäse\n\nThis is the secōnd body line") # No regex specified -> Config shouldn't be changed rule = rules.IgnoreByTitle() @@ -16,29 +16,29 @@ class ConfigurationRuleTests(BaseTestCase): self.assert_logged([]) # nothing logged -> nothing ignored # Matching regex -> expect config to ignore all rules - rule = rules.IgnoreByTitle({"regex": u"^Releäse(.*)"}) + rule = rules.IgnoreByTitle({"regex": "^Releäse(.*)"}) expected_config = LintConfig() expected_config.ignore = "all" rule.apply(config, commit) self.assertEqual(config, expected_config) - expected_log_message = u"DEBUG: gitlint.rules Ignoring commit because of rule 'I1': " + \ - u"Commit title 'Releäse' matches the regex '^Releäse(.*)', ignoring rules: all" + expected_log_message = "DEBUG: gitlint.rules Ignoring commit because of rule 'I1': " + \ + "Commit title 'Releäse' matches the regex '^Releäse(.*)', ignoring rules: all" self.assert_log_contains(expected_log_message) # Matching regex with specific ignore - rule = rules.IgnoreByTitle({"regex": u"^Releäse(.*)", + rule = rules.IgnoreByTitle({"regex": "^Releäse(.*)", "ignore": "T1,B2"}) expected_config = LintConfig() expected_config.ignore = "T1,B2" rule.apply(config, commit) self.assertEqual(config, expected_config) - expected_log_message = u"DEBUG: gitlint.rules Ignoring commit because of rule 'I1': " + \ - u"Commit title 'Releäse' matches the regex '^Releäse(.*)', ignoring rules: T1,B2" + expected_log_message = "DEBUG: gitlint.rules Ignoring commit because of rule 'I1': " + \ + "Commit title 'Releäse' matches the regex '^Releäse(.*)', ignoring rules: T1,B2" def test_ignore_by_body(self): - commit = self.gitcommit(u"Tïtle\n\nThis is\n a relëase body\n line") + commit = self.gitcommit("Tïtle\n\nThis is\n a relëase body\n line") # No regex specified -> Config shouldn't be changed rule = rules.IgnoreByBody() @@ -48,32 +48,32 @@ class ConfigurationRuleTests(BaseTestCase): self.assert_logged([]) # nothing logged -> nothing ignored # Matching regex -> expect config to ignore all rules - rule = rules.IgnoreByBody({"regex": u"(.*)relëase(.*)"}) + rule = rules.IgnoreByBody({"regex": "(.*)relëase(.*)"}) expected_config = LintConfig() expected_config.ignore = "all" rule.apply(config, commit) self.assertEqual(config, expected_config) - expected_log_message = u"DEBUG: gitlint.rules Ignoring commit because of rule 'I2': " + \ - u"Commit message line ' a relëase body' matches the regex '(.*)relëase(.*)'," + \ - u" ignoring rules: all" + expected_log_message = "DEBUG: gitlint.rules Ignoring commit because of rule 'I2': " + \ + "Commit message line ' a relëase body' matches the regex '(.*)relëase(.*)'," + \ + " ignoring rules: all" self.assert_log_contains(expected_log_message) # Matching regex with specific ignore - rule = rules.IgnoreByBody({"regex": u"(.*)relëase(.*)", + rule = rules.IgnoreByBody({"regex": "(.*)relëase(.*)", "ignore": "T1,B2"}) expected_config = LintConfig() expected_config.ignore = "T1,B2" rule.apply(config, commit) self.assertEqual(config, expected_config) - expected_log_message = u"DEBUG: gitlint.rules Ignoring commit because of rule 'I2': " + \ - u"Commit message line ' a relëase body' matches the regex '(.*)relëase(.*)', ignoring rules: T1,B2" + expected_log_message = "DEBUG: gitlint.rules Ignoring commit because of rule 'I2': " + \ + "Commit message line ' a relëase body' matches the regex '(.*)relëase(.*)', ignoring rules: T1,B2" self.assert_log_contains(expected_log_message) def test_ignore_body_lines(self): - commit1 = self.gitcommit(u"Tïtle\n\nThis is\n a relëase body\n line") - commit2 = self.gitcommit(u"Tïtle\n\nThis is\n a relëase body\n line") + commit1 = self.gitcommit("Tïtle\n\nThis is\n a relëase body\n line") + commit2 = self.gitcommit("Tïtle\n\nThis is\n a relëase body\n line") # no regex specified, nothing should have happened: # commit and config should remain identical, log should be empty @@ -85,22 +85,22 @@ class ConfigurationRuleTests(BaseTestCase): self.assert_logged([]) # Matching regex - rule = rules.IgnoreBodyLines({"regex": u"(.*)relëase(.*)"}) + rule = rules.IgnoreBodyLines({"regex": "(.*)relëase(.*)"}) config = LintConfig() rule.apply(config, commit1) # Our modified commit should be identical to a commit that doesn't contain the specific line - expected_commit = self.gitcommit(u"Tïtle\n\nThis is\n line") + expected_commit = self.gitcommit("Tïtle\n\nThis is\n line") # The original message isn't touched by this rule, this way we always have a way to reference back to it, # so assert it's not modified by setting it to the same as commit1 expected_commit.message.original = commit1.message.original self.assertEqual(commit1, expected_commit) self.assertEqual(config, LintConfig()) # config shouldn't have been modified - self.assert_log_contains(u"DEBUG: gitlint.rules Ignoring line ' a relëase body' because it " + - u"matches '(.*)relëase(.*)'") + self.assert_log_contains("DEBUG: gitlint.rules Ignoring line ' a relëase body' because it " + + "matches '(.*)relëase(.*)'") # Non-Matching regex: no changes expected - commit1 = self.gitcommit(u"Tïtle\n\nThis is\n a relëase body\n line") - rule = rules.IgnoreBodyLines({"regex": u"(.*)föobar(.*)"}) + commit1 = self.gitcommit("Tïtle\n\nThis is\n a relëase body\n line") + rule = rules.IgnoreBodyLines({"regex": "(.*)föobar(.*)"}) config = LintConfig() rule.apply(config, commit1) self.assertEqual(commit1, commit2) |