Fix Windows tests

This commit is contained in:
Sina Atalay
2025-12-09 23:53:16 +03:00
parent fcdbacba22
commit 51979c6462
9 changed files with 17 additions and 17 deletions

View File

@@ -30,7 +30,7 @@ def create_init_file_for_theme(theme_name: str, init_file_path: pathlib.Path) ->
/ "design"
/ "classic_theme.py"
)
new_init_file_contents = classic_theme_file.read_text()
new_init_file_contents = classic_theme_file.read_text(encoding="utf-8")
new_init_file_contents = new_init_file_contents.replace(
"class ClassicTheme(BaseModelWithoutExtraKeys):",
@@ -40,4 +40,4 @@ def create_init_file_for_theme(theme_name: str, init_file_path: pathlib.Path) ->
'theme: Literal["classic"] = "classic"',
f'theme: Literal["{theme_name}"] = "{theme_name}"',
)
init_file_path.write_text(new_init_file_contents)
init_file_path.write_text(new_init_file_contents, encoding="utf-8")

View File

@@ -30,6 +30,6 @@ def generate_html(
html_path = resolve_rendercv_file_path(
rendercv_model, rendercv_model.settings.render_command.html_path
)
html_contents = render_html(rendercv_model, markdown_path.read_text())
html_path.write_text(html_contents)
html_contents = render_html(rendercv_model, markdown_path.read_text(encoding="utf-8"))
html_path.write_text(html_contents, encoding="utf-8")
return html_path

View File

@@ -25,5 +25,5 @@ def generate_markdown(rendercv_model: RenderCVModel) -> pathlib.Path | None:
rendercv_model, rendercv_model.settings.render_command.markdown_path
)
markdown_contents = render_full_template(rendercv_model, "markdown")
markdown_path.write_text(markdown_contents)
markdown_path.write_text(markdown_contents, encoding="utf-8")
return markdown_path

View File

@@ -26,5 +26,5 @@ def generate_typst(rendercv_model: RenderCVModel) -> pathlib.Path | None:
rendercv_model, rendercv_model.settings.render_command.typst_path
)
typst_contents = render_full_template(rendercv_model, "typst")
typst_path.write_text(typst_contents)
typst_path.write_text(typst_contents, encoding="utf-8")
return typst_path

View File

@@ -21,7 +21,7 @@ class TestCreateInitFileForTheme:
create_init_file_for_theme(theme_name, init_file_path)
assert init_file_path.exists()
content = init_file_path.read_text()
content = init_file_path.read_text(encoding="utf-8")
assert f'theme: Literal["{theme_name}"]' in content
assert f"{theme_name.capitalize()}Theme" in content

View File

@@ -20,7 +20,7 @@ class TestCliCommandCreateTheme:
assert (theme_folder / "__init__.py").exists()
assert (theme_folder / "Preamble.j2.typ").exists()
init_content = (theme_folder / "__init__.py").read_text()
init_content = (theme_folder / "__init__.py").read_text(encoding="utf-8")
assert f'theme: Literal["{theme_name}"]' in init_content
def test_raises_error_if_folder_exists(self, tmp_path):

View File

@@ -32,7 +32,7 @@ class TestCliCommandNew:
# Set up pre-existing files/folders
if input_file_exists:
input_file_path.write_text("existing content")
input_file_path.write_text("existing content", encoding="utf-8")
if typst_templates_exist:
typst_folder.mkdir()
if markdown_templates_exist:
@@ -49,7 +49,7 @@ class TestCliCommandNew:
# If input file existed before, content should be unchanged
if input_file_exists:
assert input_file_path.read_text() == "existing content"
assert input_file_path.read_text(encoding="utf-8") == "existing content"
else:
# Make sure it's a valid YAML file
build_rendercv_dictionary_and_model(input_file_path)

View File

@@ -80,7 +80,7 @@ class TestTimedStep:
class TestRunRendercv:
def test_invalid_yaml(self, tmp_path):
invalid_yaml = tmp_path / "invalid.yaml"
invalid_yaml.write_text("invalid: yaml: content: :")
invalid_yaml.write_text("invalid: yaml: content: :", encoding="utf-8")
progress = ProgressPanel(quiet=True)
@@ -91,7 +91,7 @@ class TestRunRendercv:
def test_invalid_input_file(self, tmp_path):
invalid_schema = tmp_path / "invalid_schema.yaml"
invalid_schema.write_text("cv:\n name: 123")
invalid_schema.write_text("cv:\n name: 123", encoding="utf-8")
progress = ProgressPanel(quiet=True)

View File

@@ -23,7 +23,7 @@ class TestRunFunctionIfFileChanges:
def test_calls_function_when_file_changes(self, tmp_path):
watched_file = tmp_path / "test.yaml"
watched_file.write_text("initial")
watched_file.write_text("initial", encoding="utf-8")
call_count = 0
@@ -41,14 +41,14 @@ class TestRunFunctionIfFileChanges:
time.sleep(0.2)
initial_count = call_count
watched_file.write_text("first edit")
watched_file.write_text("first edit", encoding="utf-8")
time.sleep(0.2)
assert call_count > initial_count
def test_continues_running_after_function_raises_typer_exit(self, tmp_path):
watched_file = tmp_path / "test.yaml"
watched_file.write_text("initial")
watched_file.write_text("initial", encoding="utf-8")
call_count = 0
should_raise = False
@@ -69,14 +69,14 @@ class TestRunFunctionIfFileChanges:
time.sleep(0.2)
should_raise = True
count_before_exit = call_count
watched_file.write_text("edit that raises exit")
watched_file.write_text("edit that raises exit", encoding="utf-8")
time.sleep(0.2)
assert call_count > count_before_exit
should_raise = False
count_after_exit = call_count
watched_file.write_text("edit after exit")
watched_file.write_text("edit after exit", encoding="utf-8")
time.sleep(0.2)
assert call_count > count_after_exit