summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitlab/tests/test_gitlab.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py
index bd968b1..835e035 100644
--- a/gitlab/tests/test_gitlab.py
+++ b/gitlab/tests/test_gitlab.py
@@ -673,14 +673,15 @@ class TestGitlab(unittest.TestCase):
self.assertEqual(status.emoji, "thumbsup")
def test_todo(self):
- todo_content = open(os.path.dirname(__file__) + "/data/todo.json", "r").read()
- json_content = json.loads(todo_content)
+ with open(os.path.dirname(__file__) + "/data/todo.json", "r") as json_file:
+ todo_content = json_file.read()
+ json_content = json.loads(todo_content)
+ encoded_content = todo_content.encode("utf-8")
@urlmatch(scheme="http", netloc="localhost", path="/api/v4/todos", method="get")
def resp_get_todo(url, request):
headers = {"content-type": "application/json"}
- content = todo_content.encode("utf-8")
- return response(200, content, headers, None, 5, request)
+ return response(200, encoded_content, headers, None, 5, request)
@urlmatch(
scheme="http",