From 20150fdcf30d0c8be908ba51d05cbd8c23a8ca05 Mon Sep 17 00:00:00 2001 From: boukeversteegh Date: Sun, 24 May 2020 19:58:49 +0200 Subject: [PATCH] Cleanup --- betterproto/tests/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/betterproto/tests/util.py b/betterproto/tests/util.py index 83cfd98..11d5052 100644 --- a/betterproto/tests/util.py +++ b/betterproto/tests/util.py @@ -48,3 +48,14 @@ def protoc_reference(path: str, output_dir: str): f"protoc --python_out={output_dir} --proto_path={path} {path}/*.proto", shell=True, ) + + +def get_test_case_json_data(test_case_name, json_file_name=None): + test_data_file_name = json_file_name if json_file_name else f"{test_case_name}.json" + test_data_file_path = os.path.join(inputs_path, test_case_name, test_data_file_name) + + if not os.path.exists(test_data_file_path): + return None + + with open(test_data_file_path) as fh: + return fh.read()