From ce60b31ad466403392d710ca13b9bd1f878057d5 Mon Sep 17 00:00:00 2001 From: Lili Nie Date: Sun, 4 Feb 2024 07:19:02 -0500 Subject: [PATCH] feat: Handle non-json file for get_data function --- tests/unit/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/utils.py b/tests/unit/utils.py index 6f984f0d..4f57b83f 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -11,7 +11,10 @@ def test_dir_path(): def get_data(name, data_dir="data"): path = os.path.join(test_dir_path(), data_dir, name) with open(os.path.expanduser(path), "r", encoding="utf-8") as file_data: - data = json.load(file_data) + if name.endswith("json"): + data = json.load(file_data) + else: + data = file_data.read() return data