@@ -66,23 +66,23 @@ def test_generates_index_html(self, output_dir, snapshot_html):
6666 fixture_path = Path (__file__ ).parent / "sample_session.json"
6767 generate_html (fixture_path , output_dir , github_repo = "example/project" )
6868
69- index_html = (output_dir / "index.html" ).read_text ()
69+ index_html = (output_dir / "index.html" ).read_text (encoding = "utf-8" )
7070 assert index_html == snapshot_html
7171
7272 def test_generates_page_001_html (self , output_dir , snapshot_html ):
7373 """Test page-001.html generation."""
7474 fixture_path = Path (__file__ ).parent / "sample_session.json"
7575 generate_html (fixture_path , output_dir , github_repo = "example/project" )
7676
77- page_html = (output_dir / "page-001.html" ).read_text ()
77+ page_html = (output_dir / "page-001.html" ).read_text (encoding = "utf-8" )
7878 assert page_html == snapshot_html
7979
8080 def test_generates_page_002_html (self , output_dir , snapshot_html ):
8181 """Test page-002.html generation (continuation page)."""
8282 fixture_path = Path (__file__ ).parent / "sample_session.json"
8383 generate_html (fixture_path , output_dir , github_repo = "example/project" )
8484
85- page_html = (output_dir / "page-002.html" ).read_text ()
85+ page_html = (output_dir / "page-002.html" ).read_text (encoding = "utf-8" )
8686 assert page_html == snapshot_html
8787
8888 def test_github_repo_autodetect (self , sample_session ):
@@ -346,16 +346,16 @@ def test_injects_js_into_html_files(self, output_dir):
346346 """Test that JS is injected before </body> tag."""
347347 # Create test HTML files
348348 (output_dir / "index.html" ).write_text (
349- "<html><body><h1>Test</h1></body></html>"
349+ "<html><body><h1>Test</h1></body></html>" , encoding = "utf-8"
350350 )
351351 (output_dir / "page-001.html" ).write_text (
352- "<html><body><p>Page 1</p></body></html>"
352+ "<html><body><p>Page 1</p></body></html>" , encoding = "utf-8"
353353 )
354354
355355 inject_gist_preview_js (output_dir )
356356
357- index_content = (output_dir / "index.html" ).read_text ()
358- page_content = (output_dir / "page-001.html" ).read_text ()
357+ index_content = (output_dir / "index.html" ).read_text (encoding = "utf-8" )
358+ page_content = (output_dir / "page-001.html" ).read_text (encoding = "utf-8" )
359359
360360 # Check JS was injected
361361 assert GIST_PREVIEW_JS in index_content
@@ -368,11 +368,13 @@ def test_injects_js_into_html_files(self, output_dir):
368368 def test_skips_files_without_body (self , output_dir ):
369369 """Test that files without </body> are not modified."""
370370 original_content = "<html><head><title>Test</title></head></html>"
371- (output_dir / "fragment.html" ).write_text (original_content )
371+ (output_dir / "fragment.html" ).write_text (original_content , encoding = "utf-8" )
372372
373373 inject_gist_preview_js (output_dir )
374374
375- assert (output_dir / "fragment.html" ).read_text () == original_content
375+ assert (output_dir / "fragment.html" ).read_text (
376+ encoding = "utf-8"
377+ ) == original_content
376378
377379 def test_handles_empty_directory (self , output_dir ):
378380 """Test that empty directories don't cause errors."""
@@ -389,8 +391,12 @@ def test_creates_gist_successfully(self, output_dir, monkeypatch):
389391 import click
390392
391393 # Create test HTML files
392- (output_dir / "index.html" ).write_text ("<html><body>Index</body></html>" )
393- (output_dir / "page-001.html" ).write_text ("<html><body>Page</body></html>" )
394+ (output_dir / "index.html" ).write_text (
395+ "<html><body>Index</body></html>" , encoding = "utf-8"
396+ )
397+ (output_dir / "page-001.html" ).write_text (
398+ "<html><body>Page</body></html>" , encoding = "utf-8"
399+ )
394400
395401 # Mock subprocess.run to simulate successful gh gist create
396402 mock_result = subprocess .CompletedProcess (
@@ -425,7 +431,9 @@ def test_raises_on_gh_cli_error(self, output_dir, monkeypatch):
425431 import click
426432
427433 # Create test HTML file
428- (output_dir / "index.html" ).write_text ("<html><body>Test</body></html>" )
434+ (output_dir / "index.html" ).write_text (
435+ "<html><body>Test</body></html>" , encoding = "utf-8"
436+ )
429437
430438 # Mock subprocess.run to simulate gh error
431439 def mock_run (* args , ** kwargs ):
@@ -448,7 +456,9 @@ def test_raises_on_gh_not_found(self, output_dir, monkeypatch):
448456 import click
449457
450458 # Create test HTML file
451- (output_dir / "index.html" ).write_text ("<html><body>Test</body></html>" )
459+ (output_dir / "index.html" ).write_text (
460+ "<html><body>Test</body></html>" , encoding = "utf-8"
461+ )
452462
453463 # Mock subprocess.run to simulate gh not found
454464 def mock_run (* args , ** kwargs ):
@@ -533,7 +543,7 @@ def mock_run(*args, **kwargs):
533543 assert result .exit_code == 0
534544 assert (output_dir / "index.html" ).exists ()
535545 # Verify JS was injected
536- index_content = (output_dir / "index.html" ).read_text ()
546+ index_content = (output_dir / "index.html" ).read_text (encoding = "utf-8" )
537547 assert "gistpreview.github.io" in index_content
538548
539549
@@ -621,13 +631,13 @@ def test_long_text_in_continuation_appears_in_index(self, output_dir):
621631
622632 # Write the session to a temp file
623633 session_file = output_dir / "test_session.json"
624- session_file .write_text (json .dumps (session_data ))
634+ session_file .write_text (json .dumps (session_data ), encoding = "utf-8" )
625635
626636 # Generate HTML
627637 generate_html (session_file , output_dir )
628638
629639 # Read the index.html
630- index_html = (output_dir / "index.html" ).read_text ()
640+ index_html = (output_dir / "index.html" ).read_text (encoding = "utf-8" )
631641
632642 # The long text summary should appear in the index
633643 # This is the bug: currently it doesn't because the continuation
@@ -942,7 +952,7 @@ def test_jsonl_generates_html(self, output_dir, snapshot_html):
942952 fixture_path = Path (__file__ ).parent / "sample_session.jsonl"
943953 generate_html (fixture_path , output_dir )
944954
945- index_html = (output_dir / "index.html" ).read_text ()
955+ index_html = (output_dir / "index.html" ).read_text (encoding = "utf-8" )
946956 assert "hello world" in index_html .lower ()
947957 assert index_html == snapshot_html
948958
@@ -968,7 +978,7 @@ def test_gets_first_user_message_if_no_summary(self, tmp_path):
968978 def test_returns_no_summary_for_empty_file (self , tmp_path ):
969979 """Test handling empty or invalid files."""
970980 jsonl_file = tmp_path / "empty.jsonl"
971- jsonl_file .write_text ("" )
981+ jsonl_file .write_text ("" , encoding = "utf-8" )
972982 summary = get_session_summary (jsonl_file )
973983 assert summary == "(no summary)"
974984
0 commit comments