commit 2adcf93362fa055872b57009aeeeaae49493c323 parent 85efc9e4472d90b9371fc5ae5f04372410af7ee9 Author: Sheng <webmaster0115@gmail.com> Date: Tue, 18 Sep 2018 20:56:34 +0800 Updated tests/utils.py Diffstat:
M | tests/utils.py | | | 9 | +++++---- |
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/tests/utils.py b/tests/utils.py @@ -41,10 +41,11 @@ def get_content_type(filename): def read_file(path, encoding='utf-8'): - data = open(path, 'rb').read() - if encoding is None: - return data - return data.decode(encoding) + with open(path, 'rb') as f: + data = f.read() + if encoding is None: + return data + return data.decode(encoding) def make_tests_data_path(filename):