Skip to content

Commit

Permalink
handle non-json file for get_data function
Browse files Browse the repository at this point in the history
  • Loading branch information
skycastlelily committed Feb 4, 2024
1 parent ab412cc commit af31717
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tests/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit af31717

Please sign in to comment.