Skip to content

Commit ff808ee

Browse files
authored
Merge pull request #908 from derekschrock/todo-units-test
Remove warning about open files from test_todo()
2 parents 92ba028 + d6419aa commit ff808ee

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

gitlab/tests/test_gitlab.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -673,14 +673,15 @@ def resp_get_user_status(url, request):
673673
self.assertEqual(status.emoji, "thumbsup")
674674

675675
def test_todo(self):
676-
todo_content = open(os.path.dirname(__file__) + "/data/todo.json", "r").read()
677-
json_content = json.loads(todo_content)
676+
with open(os.path.dirname(__file__) + "/data/todo.json", "r") as json_file:
677+
todo_content = json_file.read()
678+
json_content = json.loads(todo_content)
679+
encoded_content = todo_content.encode("utf-8")
678680

679681
@urlmatch(scheme="http", netloc="localhost", path="/api/v4/todos", method="get")
680682
def resp_get_todo(url, request):
681683
headers = {"content-type": "application/json"}
682-
content = todo_content.encode("utf-8")
683-
return response(200, content, headers, None, 5, request)
684+
return response(200, encoded_content, headers, None, 5, request)
684685

685686
@urlmatch(
686687
scheme="http",

0 commit comments

Comments
 (0)