summaryrefslogtreecommitdiffstats
path: root/qa
diff options
context:
space:
mode:
Diffstat (limited to 'qa')
-rw-r--r--qa/base.py3
-rw-r--r--qa/samples/user_rules/extra/extra_rules.py16
-rw-r--r--qa/test_commits.py2
-rw-r--r--qa/test_gitlint.py7
-rw-r--r--qa/test_hooks.py6
5 files changed, 17 insertions, 17 deletions
diff --git a/qa/base.py b/qa/base.py
index 02118d7..2dd2715 100644
--- a/qa/base.py
+++ b/qa/base.py
@@ -57,7 +57,8 @@ class BaseTestCase(TestCase):
@classmethod
def generate_temp_path(cls):
- return os.path.realpath("/tmp/gitlint-test-{0}".format(datetime.now().strftime("%Y%m%d-%H%M%S-%f")))
+ timestamp = datetime.now().strftime("%Y%m%d-%H%M%S-%f")
+ return os.path.realpath(f"/tmp/gitlint-test-{timestamp}")
@classmethod
def create_tmp_git_repo(cls):
diff --git a/qa/samples/user_rules/extra/extra_rules.py b/qa/samples/user_rules/extra/extra_rules.py
index 64c6528..9a0ae6d 100644
--- a/qa/samples/user_rules/extra/extra_rules.py
+++ b/qa/samples/user_rules/extra/extra_rules.py
@@ -11,8 +11,8 @@ class GitContextRule(CommitRule):
def validate(self, commit):
violations = [
- RuleViolation(self.id, "GitContext.current_branch: {0}".format(commit.context.current_branch), line_nr=1),
- RuleViolation(self.id, "GitContext.commentchar: {0}".format(commit.context.commentchar), line_nr=1)
+ RuleViolation(self.id, f"GitContext.current_branch: {commit.context.current_branch}", line_nr=1),
+ RuleViolation(self.id, f"GitContext.commentchar: {commit.context.commentchar}", line_nr=1)
]
return violations
@@ -25,8 +25,8 @@ class GitCommitRule(CommitRule):
def validate(self, commit):
violations = [
- RuleViolation(self.id, "GitCommit.branches: {0}".format(commit.branches), line_nr=1),
- RuleViolation(self.id, "GitCommit.custom_prop: {0}".format(commit.custom_prop), line_nr=1),
+ RuleViolation(self.id, f"GitCommit.branches: {commit.branches}", line_nr=1),
+ RuleViolation(self.id, f"GitCommit.custom_prop: {commit.custom_prop}", line_nr=1),
]
return violations
@@ -40,7 +40,7 @@ class GitlintConfigurationRule(ConfigurationRule):
def apply(self, config, commit):
# We add a line to the commit message body that pulls a value from config, this proves we can modify the body
# and read the config contents
- commit.message.body.append("{0} ".format(config.target)) # trailing whitespace deliberate to trigger violation
+ commit.message.body.append(f"{config.target} ") # trailing whitespace deliberate to trigger violation
# We set a custom property that we access in CommitRule, to prove we can add extra properties to the commit
commit.custom_prop = "foöbar"
@@ -60,9 +60,9 @@ class ConfigurableCommitRule(CommitRule):
def validate(self, _):
violations = [
- RuleViolation(self.id, "int-öption: {0}".format(self.options[u'int-öption'].value), line_nr=1),
- RuleViolation(self.id, "str-öption: {0}".format(self.options[u'str-öption'].value), line_nr=1),
- RuleViolation(self.id, "list-öption: {0}".format(self.options[u'list-öption'].value), line_nr=1),
+ RuleViolation(self.id, f"int-öption: {self.options[u'int-öption'].value}", line_nr=1),
+ RuleViolation(self.id, f"str-öption: {self.options[u'str-öption'].value}", line_nr=1),
+ RuleViolation(self.id, f"list-öption: {self.options[u'list-öption'].value}", line_nr=1),
]
return violations
diff --git a/qa/test_commits.py b/qa/test_commits.py
index eace0b6..389ad66 100644
--- a/qa/test_commits.py
+++ b/qa/test_commits.py
@@ -45,7 +45,7 @@ class CommitsTests(BaseTestCase):
self.create_simple_commit("Sïmple title.\n")
self.create_simple_commit("Sïmple title2.\n")
commit_sha = self.get_last_commit_hash()
- refspec = "{0}^...{0}".format(commit_sha)
+ refspec = f"{commit_sha}^...{commit_sha}"
self.create_simple_commit("Sïmple title3.\n")
output = gitlint("--commits", refspec, _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[2])
expected = ("1: T3 Title has trailing punctuation (.): \"Sïmple title2.\"\n" +
diff --git a/qa/test_gitlint.py b/qa/test_gitlint.py
index 0f17c77..0200d76 100644
--- a/qa/test_gitlint.py
+++ b/qa/test_gitlint.py
@@ -34,14 +34,14 @@ class IntegrationTests(BaseTestCase):
git("checkout", "-b", "test-branch", _cwd=self.tmp_git_repo)
git("checkout", "test-branch", _cwd=self.tmp_git_repo)
commit_title = "Commit on test-brånch with a pretty long title that will cause issues when merging"
- self.create_simple_commit("{0}\n\nSïmple body".format(commit_title))
+ self.create_simple_commit(f"{commit_title}\n\nSïmple body")
hash = self.get_last_commit_hash()
# Checkout master and merge the commit
# We explicitly set the title of the merge commit to the title of the previous commit as this or similar
# behavior is what many tools do that handle merges (like github, gerrit, etc).
git("checkout", "master", _cwd=self.tmp_git_repo)
- git("merge", "--no-ff", "-m", "Merge '{0}'".format(commit_title), hash, _cwd=self.tmp_git_repo)
+ git("merge", "--no-ff", "-m", f"Merge '{commit_title}'", hash, _cwd=self.tmp_git_repo)
# Run gitlint and assert output is empty
output = gitlint(_cwd=self.tmp_git_repo, _tty_in=True)
@@ -50,8 +50,7 @@ class IntegrationTests(BaseTestCase):
# Assert that we do see the error if we disable the ignore-merge-commits option
output = gitlint("-c", "general.ignore-merge-commits=false", _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[1])
self.assertEqual(output.exit_code, 1)
- self.assertEqualStdout(output,
- "1: T1 Title exceeds max length (90>72): \"Merge '{0}'\"\n".format(commit_title))
+ self.assertEqualStdout(output, f"1: T1 Title exceeds max length (90>72): \"Merge '{commit_title}'\"\n")
def test_fixup_commit(self):
# Create a normal commit and assert that it has a violation
diff --git a/qa/test_hooks.py b/qa/test_hooks.py
index 28b47a8..0ad3491 100644
--- a/qa/test_hooks.py
+++ b/qa/test_hooks.py
@@ -50,7 +50,7 @@ class HookTests(BaseTestCase):
# Answer 'yes' to question to keep violating commit-msg
if "Your commit message contains the above violations" in line:
response = self.responses[self.response_index]
- stdin.put("{0}\n".format(response))
+ stdin.put(f"{response}\n")
self.response_index = (self.response_index + 1) % len(self.responses)
def test_commit_hook_no_violations(self):
@@ -156,10 +156,10 @@ class HookTests(BaseTestCase):
output_installed = gitlint("install-hook", _cwd=worktree_dir)
expected_hook_path = os.path.join(tmp_git_repo, ".git", "hooks", "commit-msg")
- expected_msg = "Successfully installed gitlint commit-msg hook in {0}\n".format(expected_hook_path)
+ expected_msg = f"Successfully installed gitlint commit-msg hook in {expected_hook_path}\n"
self.assertEqual(output_installed, expected_msg)
output_uninstalled = gitlint("uninstall-hook", _cwd=worktree_dir)
expected_hook_path = os.path.join(tmp_git_repo, ".git", "hooks", "commit-msg")
- expected_msg = "Successfully uninstalled gitlint commit-msg hook from {0}\n".format(expected_hook_path)
+ expected_msg = f"Successfully uninstalled gitlint commit-msg hook from {expected_hook_path}\n"
self.assertEqual(output_uninstalled, expected_msg)