Skip to content

Commit 805aca8

Browse files
committed
windows again bro
1 parent d68d1ea commit 805aca8

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

.github/actions/run-rust-python-tests/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,7 @@ runs:
6363
6464
- name: Run pytest
6565
shell: bash
66+
env:
67+
PYTHONUTF8: "1"
6668
run: |
6769
pytest -q

tests/test_harmony.py

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def _assert_tokens_eq(encoding, expected: List[int], actual: List[int]): # type
5959

6060

6161
def read_expected_tokens(file_path: Path) -> List[int]:
62-
with open(file_path, "r") as f:
62+
with open(file_path, "r", encoding="utf-8") as f:
6363
return [int(x) for x in f.read().split()]
6464

6565

@@ -78,7 +78,9 @@ def test_simple_convo(encoding_name):
7878
encoding = load_harmony_encoding(encoding_name)
7979

8080
expected_text = (
81-
(ROOT_DIR / "test-data" / "test_simple_convo.txt").read_text().rstrip()
81+
(ROOT_DIR / "test-data" / "test_simple_convo.txt")
82+
.read_text(encoding="utf-8")
83+
.rstrip()
8284
)
8385
expected_tokens = encoding.encode(expected_text, allowed_special="all")
8486

@@ -143,7 +145,7 @@ def test_simple_convo_with_effort(encoding_name):
143145
]
144146

145147
for effort, tokens_path, use_instruction in test_cases:
146-
expected_text = tokens_path.read_text().rstrip()
148+
expected_text = tokens_path.read_text(encoding="utf-8").rstrip()
147149
expected_tokens = encoding.encode(expected_text, allowed_special="all")
148150
sys = (
149151
SystemContent.new()
@@ -299,7 +301,7 @@ def test_reasoning_system_message(encoding_name):
299301

300302
expected_text = (
301303
(ROOT_DIR / "test-data" / "test_reasoning_system_message.txt")
302-
.read_text()
304+
.read_text(encoding="utf-8")
303305
.rstrip()
304306
)
305307
expected = encoding.encode(expected_text, allowed_special="all")
@@ -336,7 +338,7 @@ def test_reasoning_system_message_no_instruction(encoding_name):
336338

337339
expected_text = (
338340
(ROOT_DIR / "test-data" / "test_reasoning_system_message_no_instruction.txt")
339-
.read_text()
341+
.read_text(encoding="utf-8")
340342
.rstrip()
341343
)
342344
expected = encoding.encode(expected_text, allowed_special="all")
@@ -376,7 +378,7 @@ def test_reasoning_system_message_with_dates(encoding_name):
376378

377379
expected_text = (
378380
(ROOT_DIR / "test-data" / "test_reasoning_system_message_with_dates.txt")
379-
.read_text()
381+
.read_text(encoding="utf-8")
380382
.rstrip()
381383
)
382384
expected = encoding.encode(expected_text, allowed_special="all")
@@ -409,7 +411,7 @@ def test_render_functions_with_parameters():
409411

410412
expected_output = (
411413
(ROOT_DIR / "test-data" / "test_render_functions_with_parameters.txt")
412-
.read_text()
414+
.read_text(encoding="utf-8")
413415
.rstrip()
414416
)
415417

@@ -526,7 +528,9 @@ def test_render_functions_with_parameters():
526528
def test_no_tools():
527529
encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
528530
expected_output = (
529-
(ROOT_DIR / "test-data" / "test_no_tools.txt").read_text().rstrip()
531+
(ROOT_DIR / "test-data" / "test_no_tools.txt")
532+
.read_text(encoding="utf-8")
533+
.rstrip()
530534
)
531535

532536
convo = Conversation.from_messages(
@@ -546,7 +550,9 @@ def test_no_tools():
546550
def test_browser_tool_only():
547551
encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
548552
expected_output = (
549-
(ROOT_DIR / "test-data" / "test_browser_tool_only.txt").read_text().rstrip()
553+
(ROOT_DIR / "test-data" / "test_browser_tool_only.txt")
554+
.read_text(encoding="utf-8")
555+
.rstrip()
550556
)
551557

552558
convo = Conversation.from_messages(
@@ -569,7 +575,7 @@ def test_browser_and_function_tool():
569575
encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
570576
expected_output = (
571577
(ROOT_DIR / "test-data" / "test_browser_and_function_tool.txt")
572-
.read_text()
578+
.read_text(encoding="utf-8")
573579
.rstrip()
574580
)
575581

@@ -611,7 +617,7 @@ def test_browser_and_python_tool():
611617
encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
612618
expected_output = (
613619
(ROOT_DIR / "test-data" / "test_browser_and_python_tool.txt")
614-
.read_text()
620+
.read_text(encoding="utf-8")
615621
.rstrip()
616622
)
617623

@@ -637,7 +643,7 @@ def test_dropping_cot_by_default():
637643

638644
expected_output = (
639645
(ROOT_DIR / "test-data" / "test_dropping_cot_by_default.txt")
640-
.read_text()
646+
.read_text(encoding="utf-8")
641647
.rstrip()
642648
)
643649

@@ -667,7 +673,7 @@ def test_does_not_drop_if_ongoing_analysis():
667673

668674
expected_output = (
669675
(ROOT_DIR / "test-data" / "test_does_not_drop_if_ongoing_analysis.txt")
670-
.read_text()
676+
.read_text(encoding="utf-8")
671677
.rstrip()
672678
)
673679

@@ -702,7 +708,9 @@ def test_preserve_cot():
702708
encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
703709

704710
expected_output = (
705-
(ROOT_DIR / "test-data" / "test_preserve_cot.txt").read_text().rstrip()
711+
(ROOT_DIR / "test-data" / "test_preserve_cot.txt")
712+
.read_text(encoding="utf-8")
713+
.rstrip()
706714
)
707715

708716
convo = Conversation.from_messages(
@@ -738,7 +746,7 @@ def test_keep_analysis_between_final_messages():
738746

739747
expected_output = (
740748
(ROOT_DIR / "test-data" / "test_keep_analysis_between_finals.txt")
741-
.read_text()
749+
.read_text(encoding="utf-8")
742750
.rstrip()
743751
)
744752

@@ -880,7 +888,9 @@ def test_tool_response_parsing():
880888
encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
881889

882890
text_tokens = (
883-
(ROOT_DIR / "test-data" / "test_tool_response_parsing.txt").read_text().rstrip()
891+
(ROOT_DIR / "test-data" / "test_tool_response_parsing.txt")
892+
.read_text(encoding="utf-8")
893+
.rstrip()
884894
)
885895

886896
expected_message = (
@@ -904,7 +914,9 @@ def test_streamable_parser():
904914
encoding = load_harmony_encoding(HarmonyEncodingName.HARMONY_GPT_OSS)
905915

906916
text_tokens = (
907-
(ROOT_DIR / "test-data" / "test_streamable_parser.txt").read_text().rstrip()
917+
(ROOT_DIR / "test-data" / "test_streamable_parser.txt")
918+
.read_text(encoding="utf-8")
919+
.rstrip()
908920
)
909921

910922
tokens = encoding.encode(text_tokens, allowed_special="all")

0 commit comments

Comments
 (0)