Browse Source

♻️ Update file read with explicit encoding because Windows

pull/14684/head
Sebastián Ramírez 6 months ago
parent
commit
7a82b13dff
  1. 2
      scripts/docs.py
  2. 2
      scripts/notify_translations.py
  3. 16
      scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_lines_number_mismatch.py
  4. 8
      scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_mermaid.py
  5. 12
      scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_number_mismatch.py
  6. 12
      scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_wrong_lang_code.py
  7. 12
      scripts/tests/test_translation_fixer/test_code_includes/test_number_mismatch.py
  8. 4
      scripts/tests/test_translation_fixer/test_complex_doc/test_compex_doc.py
  9. 8
      scripts/tests/test_translation_fixer/test_header_permalinks/test_header_level_mismatch.py
  10. 12
      scripts/tests/test_translation_fixer/test_header_permalinks/test_header_number_mismatch.py
  11. 12
      scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py
  12. 12
      scripts/tests/test_translation_fixer/test_markdown_links/test_mkd_links_number_mismatch.py

2
scripts/docs.py

@ -239,7 +239,7 @@ def generate_readme() -> None:
Generate README.md content from main index.md
"""
readme_path = Path("README.md")
old_content = readme_path.read_text()
old_content = readme_path.read_text("utf-8")
new_content = generate_readme_content()
if new_content != old_content:
print("README.md outdated from the latest index.md")

2
scripts/notify_translations.py

@ -316,7 +316,7 @@ def main() -> None:
raise RuntimeError(
f"No github event file available at: {settings.github_event_path}"
)
contents = settings.github_event_path.read_text()
contents = settings.github_event_path.read_text("utf-8")
github_event = PartialGitHubEvent.model_validate_json(contents)
logging.info(f"Using GitHub event: {github_event}")
number = (

16
scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_lines_number_mismatch.py

@ -22,10 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(
f"{data_path}/translated_doc_lines_number_gt.md"
).read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_lines_number_gt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output
@ -46,10 +46,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
)
# assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(
f"{data_path}/translated_doc_lines_number_lt.md"
).read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_lines_number_lt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output

8
scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_mermaid.py

@ -22,10 +22,10 @@ def test_translated(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 0, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(
f"{data_path}/translated_doc_mermaid_translated.md"
).read_text()
).read_text("utf-8")
assert fixed_content == expected_content # Translated doc remains unchanged
assert (
@ -50,10 +50,10 @@ def test_not_translated(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 0, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(
f"{data_path}/translated_doc_mermaid_not_translated.md"
).read_text()
).read_text("utf-8")
assert fixed_content == expected_content # Translated doc remains unchanged
assert ("Skipping mermaid code block replacement") not in result.output

12
scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_number_mismatch.py

@ -22,8 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output
@ -45,8 +47,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
)
# assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output

12
scripts/tests/test_translation_fixer/test_code_blocks/test_code_blocks_wrong_lang_code.py

@ -22,10 +22,10 @@ def test_wrong_lang_code_1(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(
f"{data_path}/translated_doc_wrong_lang_code.md"
).read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_wrong_lang_code.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output
@ -46,10 +46,10 @@ def test_wrong_lang_code_2(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(
f"{data_path}/translated_doc_wrong_lang_code_2.md"
).read_text()
).read_text("utf-8")
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output

12
scripts/tests/test_translation_fixer/test_code_includes/test_number_mismatch.py

@ -22,8 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output
@ -45,8 +47,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output

4
scripts/tests/test_translation_fixer/test_complex_doc/test_compex_doc.py

@ -22,8 +22,8 @@ def test_fix(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 0, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = (data_path / "translated_doc_expected.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = (data_path / "translated_doc_expected.md").read_text("utf-8")
assert fixed_content == expected_content
assert "Fixing multiline code blocks in" in result.output

8
scripts/tests/test_translation_fixer/test_header_permalinks/test_header_level_mismatch.py

@ -22,10 +22,10 @@ def test_level_mismatch_1(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(
f"{data_path}/translated_doc_level_mismatch_1.md"
).read_text()
).read_text("utf-8")
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output
@ -47,10 +47,10 @@ def test_level_mismatch_2(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(
f"{data_path}/translated_doc_level_mismatch_2.md"
).read_text()
).read_text("utf-8")
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output

12
scripts/tests/test_translation_fixer/test_header_permalinks/test_header_number_mismatch.py

@ -22,8 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output
@ -45,8 +47,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output

12
scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py

@ -20,8 +20,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output
@ -43,8 +45,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
)
# assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output

12
scripts/tests/test_translation_fixer/test_markdown_links/test_mkd_links_number_mismatch.py

@ -22,8 +22,10 @@ def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
)
assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output
@ -45,8 +47,10 @@ def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
)
# assert result.exit_code == 1, result.output
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text("utf-8")
expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text(
"utf-8"
)
assert fixed_content == expected_content # Translated doc remains unchanged
assert "Error processing docs/lang/docs/doc.md" in result.output

Loading…
Cancel
Save