From d4707f78206f4be9136b97635f3b160fd20f1219 Mon Sep 17 00:00:00 2001 From: Ghraven Date: Mon, 27 Jul 2026 06:50:05 +0800 Subject: [PATCH] Use UTF-8 for test case JSON files --- burr/cli/__main__.py | 4 ++-- burr/lifecycle/default.py | 2 +- burr/testing/__init__.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/burr/cli/__main__.py b/burr/cli/__main__.py index 5bbc99dd5..8967602d9 100644 --- a/burr/cli/__main__.py +++ b/burr/cli/__main__.py @@ -477,14 +477,14 @@ def create_test_case( if target_file_name: # if it already exists, load it up and append to it if os.path.exists(target_file_name): - with open(target_file_name, "r") as f: + with open(target_file_name, "r", encoding="utf-8") as f: # assumes it's a list of test cases current_testcases = json.load(f) current_testcases.append(tc_json) else: current_testcases = [tc_json] print(f"\nWriting data to file {target_file_name}") - with open(target_file_name, "w") as f: + with open(target_file_name, "w", encoding="utf-8") as f: json.dump(current_testcases, f, indent=2) else: logger.info(json.dumps(tc_json, indent=2)) diff --git a/burr/lifecycle/default.py b/burr/lifecycle/default.py index 0f7b86c95..8bc234a26 100644 --- a/burr/lifecycle/default.py +++ b/burr/lifecycle/default.py @@ -51,7 +51,7 @@ def __init__( raise ValueError(f"jsonl_path must end with .jsonl. Got: {jsonl_path}") self.jsonl_path = jsonl_path open_mode = "a" if mode == "append" else "w" - self.f = open(jsonl_path, mode=open_mode) # open in append mode + self.f = open(jsonl_path, mode=open_mode, encoding="utf-8") self.tracker = [] # tracker to keep track of timing/whatnot self.json_dump = json_dump diff --git a/burr/testing/__init__.py b/burr/testing/__init__.py index f1caa19bf..bd89af77f 100644 --- a/burr/testing/__init__.py +++ b/burr/testing/__init__.py @@ -26,7 +26,7 @@ # and then load it for the test. def load_test_cases(file_name: str) -> tuple: """Load test cases from a json file.""" - with open(file_name, "r") as f: + with open(file_name, "r", encoding="utf-8") as f: json_test_cases = json.load(f) test_cases = [(tc.get("input_state"), tc.get("expected_state")) for tc in json_test_cases] test_ids = [