diff options
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/objects/test_todos.py | 2 | ||||
-rw-r--r-- | tests/unit/test_cli.py | 2 | ||||
-rw-r--r-- | tests/unit/test_config.py | 33 | ||||
-rw-r--r-- | tests/unit/test_gitlab.py | 4 |
4 files changed, 16 insertions, 25 deletions
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) |