summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/api/test_gitlab.py4
-rw-r--r--tests/functional/api/test_keys.py2
-rw-r--r--tests/functional/api/test_projects.py2
-rw-r--r--tests/functional/api/test_repository.py4
-rwxr-xr-xtests/functional/ee-test.py2
-rw-r--r--tests/unit/objects/test_todos.py2
-rw-r--r--tests/unit/test_cli.py2
-rw-r--r--tests/unit/test_config.py33
-rw-r--r--tests/unit/test_gitlab.py4
9 files changed, 22 insertions, 33 deletions
diff --git a/tests/functional/api/test_gitlab.py b/tests/functional/api/test_gitlab.py
index 7a70a56..e79492f 100644
--- a/tests/functional/api/test_gitlab.py
+++ b/tests/functional/api/test_gitlab.py
@@ -166,13 +166,13 @@ def test_rate_limits(gl):
projects = list()
for i in range(0, 20):
- projects.append(gl.projects.create({"name": str(i) + "ok"}))
+ projects.append(gl.projects.create({"name": f"{str(i)}ok"}))
with pytest.raises(gitlab.GitlabCreateError) as e:
for i in range(20, 40):
projects.append(
gl.projects.create(
- {"name": str(i) + "shouldfail"}, obey_rate_limit=False
+ {"name": f"{str(i)}shouldfail"}, obey_rate_limit=False
)
)
diff --git a/tests/functional/api/test_keys.py b/tests/functional/api/test_keys.py
index 82a75e5..4f2f4ed 100644
--- a/tests/functional/api/test_keys.py
+++ b/tests/functional/api/test_keys.py
@@ -10,7 +10,7 @@ def key_fingerprint(key):
key_part = key.split()[1]
decoded = base64.b64decode(key_part.encode("ascii"))
digest = hashlib.sha256(decoded).digest()
- return "SHA256:" + base64.b64encode(digest).rstrip(b"=").decode("utf-8")
+ return f"SHA256:{base64.b64encode(digest).rstrip(b'=').decode('utf-8')}"
def test_keys_ssh(gl, user, SSH_KEY):
diff --git a/tests/functional/api/test_projects.py b/tests/functional/api/test_projects.py
index 0572276..3a317d5 100644
--- a/tests/functional/api/test_projects.py
+++ b/tests/functional/api/test_projects.py
@@ -108,7 +108,7 @@ def test_project_file_uploads(project):
uploaded_file = project.upload(filename, file_contents)
assert uploaded_file["alt"] == filename
assert uploaded_file["url"].startswith("/uploads/")
- assert uploaded_file["url"].endswith("/" + filename)
+ assert uploaded_file["url"].endswith(f"/{filename}")
assert uploaded_file["markdown"] == "[{}]({})".format(
uploaded_file["alt"], uploaded_file["url"]
)
diff --git a/tests/functional/api/test_repository.py b/tests/functional/api/test_repository.py
index fe43862..06d4297 100644
--- a/tests/functional/api/test_repository.py
+++ b/tests/functional/api/test_repository.py
@@ -116,9 +116,7 @@ def test_revert_commit(project):
commit = project.commits.list()[0]
revert_commit = commit.revert(branch="main")
- expected_message = 'Revert "{}"\n\nThis reverts commit {}'.format(
- commit.message, commit.id
- )
+ expected_message = f'Revert "{commit.message}"\n\nThis reverts commit {commit.id}'
assert revert_commit["message"] == expected_message
with pytest.raises(gitlab.GitlabRevertError):
diff --git a/tests/functional/ee-test.py b/tests/functional/ee-test.py
index 3a99951..a356c80 100755
--- a/tests/functional/ee-test.py
+++ b/tests/functional/ee-test.py
@@ -14,7 +14,7 @@ LDAP_PROVIDER = "ldapmain"
def start_log(message):
- print("Testing %s... " % message, end="")
+ print(f"Testing {message}... ", end="")
def end_log():
diff --git a/tests/unit/objects/test_todos.py b/tests/unit/objects/test_todos.py
index 058fe33..9d6b6b4 100644
--- a/tests/unit/objects/test_todos.py
+++ b/tests/unit/objects/test_todos.py
@@ -10,7 +10,7 @@ import responses
from gitlab.v4.objects import Todo
-with open(os.path.dirname(__file__) + "/../data/todo.json", "r") as json_file:
+with open(f"{os.path.dirname(__file__)}/../data/todo.json", "r") as json_file:
todo_content = json_file.read()
json_content = json.loads(todo_content)
diff --git a/tests/unit/test_cli.py b/tests/unit/test_cli.py
index a9ca958..d5afe69 100644
--- a/tests/unit/test_cli.py
+++ b/tests/unit/test_cli.py
@@ -91,7 +91,7 @@ def test_parse_value():
fd, temp_path = tempfile.mkstemp()
os.write(fd, b"content")
os.close(fd)
- ret = cli._parse_value("@%s" % temp_path)
+ ret = cli._parse_value(f"@{temp_path}")
assert ret == "content"
os.unlink(temp_path)
diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py
index a62106b..f7fffb2 100644
--- a/tests/unit/test_config.py
+++ b/tests/unit/test_config.py
@@ -26,7 +26,7 @@ from gitlab import config, USER_AGENT
custom_user_agent = "my-package/1.0.0"
-valid_config = u"""[global]
+valid_config = """[global]
default = one
ssl_verify = true
timeout = 2
@@ -52,24 +52,22 @@ url = https://four.url
oauth_token = STUV
"""
-custom_user_agent_config = """[global]
+custom_user_agent_config = f"""[global]
default = one
-user_agent = {}
+user_agent = {custom_user_agent}
[one]
url = http://one.url
private_token = ABCDEF
-""".format(
- custom_user_agent
-)
+"""
-no_default_config = u"""[global]
+no_default_config = """[global]
[there]
url = http://there.url
private_token = ABCDEF
"""
-missing_attr_config = u"""[global]
+missing_attr_config = """[global]
[one]
url = http://one.url
@@ -87,28 +85,24 @@ per_page = 200
def global_retry_transient_errors(value: bool) -> str:
- return u"""[global]
+ return f"""[global]
default = one
-retry_transient_errors={}
+retry_transient_errors={value}
[one]
url = http://one.url
-private_token = ABCDEF""".format(
- value
- )
+private_token = ABCDEF"""
def global_and_gitlab_retry_transient_errors(
global_value: bool, gitlab_value: bool
) -> str:
- return u"""[global]
+ return f"""[global]
default = one
retry_transient_errors={global_value}
[one]
url = http://one.url
private_token = ABCDEF
- retry_transient_errors={gitlab_value}""".format(
- global_value=global_value, gitlab_value=gitlab_value
- )
+ retry_transient_errors={gitlab_value}"""
@mock.patch.dict(os.environ, {"PYTHON_GITLAB_CFG": "/some/path"})
@@ -233,16 +227,15 @@ def test_data_from_helper(m_open, path_exists, tmp_path):
fd = io.StringIO(
dedent(
- """\
+ f"""\
[global]
default = helper
[helper]
url = https://helper.url
- oauth_token = helper: %s
+ oauth_token = helper: {helper}
"""
)
- % helper
)
fd.close = mock.Mock(return_value=None)
diff --git a/tests/unit/test_gitlab.py b/tests/unit/test_gitlab.py
index 2bd7d4d..c147fa0 100644
--- a/tests/unit/test_gitlab.py
+++ b/tests/unit/test_gitlab.py
@@ -33,9 +33,7 @@ token = "abc123"
@urlmatch(scheme="http", netloc="localhost", path="/api/v4/user", method="get")
def resp_get_user(url, request):
headers = {"content-type": "application/json"}
- content = '{{"id": {0:d}, "username": "{1:s}"}}'.format(user_id, username).encode(
- "utf-8"
- )
+ content = f'{{"id": {user_id:d}, "username": "{username:s}"}}'.encode("utf-8")
return response(200, content, headers, None, 5, request)