@@ -176,28 +176,35 @@ def test_a_page_the_reviewer_still_flags_after_the_correction_round_is_not_publi
176176 assert "words the translation never contained" not in model .requests [2 ]
177177
178178
179+ def write (path : Path , text : str ) -> None :
180+ """Write a repo file the way the tool reads it: UTF-8 with `\\ n` line endings, on every platform."""
181+ path .parent .mkdir (parents = True , exist_ok = True )
182+ path .write_text (text , encoding = "utf-8" , newline = "" )
183+
184+
179185@pytest .fixture
180186def docs_repo (tmp_path : Path , monkeypatch : pytest .MonkeyPatch ) -> Path :
181187 """A repository tree with two English pages, one Japanese translation and the ja UI strings."""
182- (tmp_path / "docs" ). mkdir ( )
183- (tmp_path / "docs" / "index .md" ). write_text ( "# Home \n \n See [tools](tools.md) and the [API](api/mcp/index.md) .\n " )
184- (tmp_path / "docs" / "tools .md" ). write_text ( "# Tools \n \n English body. \n " )
185- ( tmp_path / "docs" / "translations.md" ). write_text ( "# Translations \n " )
186- ( tmp_path / "mkdocs.yml" ). write_text (
188+ write (tmp_path / "docs" / "index.md" , "# Home \n \n See [tools](tools.md) and the [API](api/mcp/index.md). \n " )
189+ write (tmp_path / "docs" / "tools .md" , "# Tools \n \n English body .\n " )
190+ write (tmp_path / "docs" / "translations .md" , "# Translations \n " )
191+ write (
192+ tmp_path / "mkdocs.yml" ,
187193 "site_url: https://docs.example/\n nav:\n - Home: index.md\n - Tools: tools.md\n "
188- " - Translations: translations.md\n - API Reference: api/\n "
194+ " - Translations: translations.md\n - API Reference: api/\n " ,
189195 )
190- ( tmp_path / "i18n" / "ja" / "pages" ). mkdir ( parents = True )
191- ( tmp_path / "i18n" / "languages.yml" ). write_text (
196+ write (
197+ tmp_path / "i18n" / "languages.yml" ,
192198 "languages:\n - {code: ja, name: 日本語}\n exclude_pages: [translations.md]\n "
193199 "models: {translate: t, verify: v}\n banners:\n disclosure: 'MT: [English]({english_url})'\n "
194- " outdated: 'behind'\n untranslated: 'English shown, see [how]({translations_url})'\n "
200+ " outdated: 'behind'\n untranslated: 'English shown, see [how]({translations_url})'\n " ,
195201 )
196- (tmp_path / "i18n" / "general-prompt.md" ).write_text ("rules" )
197- (tmp_path / "i18n" / "ja" / "instructions.md" ).write_text ("instructions" )
198- (tmp_path / "i18n" / "ja" / "glossary.json" ).write_text (json .dumps (GLOSSARY ))
199- (tmp_path / "i18n" / "ja" / "pages" / "index.md" ).write_text (
200- "# ホーム {#home}\n \n [ツール](tools.md) と [API](api/mcp/index.md) を参照。\n "
202+ write (tmp_path / "i18n" / "general-prompt.md" , "rules" )
203+ write (tmp_path / "i18n" / "ja" / "instructions.md" , "instructions" )
204+ write (tmp_path / "i18n" / "ja" / "glossary.json" , json .dumps (GLOSSARY ))
205+ write (
206+ tmp_path / "i18n" / "ja" / "pages" / "index.md" ,
207+ "# ホーム {#home}\n \n [ツール](tools.md) と [API](api/mcp/index.md) を参照。\n " ,
201208 )
202209 for name , path in (("ROOT" , tmp_path ), ("DOCS" , tmp_path / "docs" ), ("I18N" , tmp_path / "i18n" )):
203210 monkeypatch .setattr (i18n , name , path )
@@ -216,7 +223,7 @@ def docs_repo(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
216223 "model" : "t" ,
217224 "translated_at" : "now" ,
218225 }
219- (tmp_path / "i18n" / "ja" / "state.json" ). write_text ( json .dumps ({"pages" : {"index.md" : page_record }, "ui" : ui }))
226+ write (tmp_path / "i18n" / "ja" / "state.json" , json .dumps ({"pages" : {"index.md" : page_record }, "ui" : ui }))
220227 return tmp_path
221228
222229
@@ -255,7 +262,7 @@ def test_status_marks_pages_current_outdated_and_missing_from_content_and_input_
255262) -> None :
256263 """SDK-defined: a page is current only while both the English text and the prompt inputs it was translated from
257264 are unchanged; editing the English makes it outdated, and a page with no translation is missing."""
258- (docs_repo / "docs" / "index.md" ). write_text ( "# Home\n \n The English changed since translation.\n " )
265+ write (docs_repo / "docs" / "index.md" , "# Home\n \n The English changed since translation.\n " )
259266
260267 exit_code = i18n .command_status (i18n .load_registry (), None )
261268
0 commit comments