Skip to content

Commit

Permalink
Fix warnings in the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
Secrus authored and abn committed Jan 16, 2025
1 parent 2e8e4e0 commit 81f2935
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/config/test_file_config_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_file_config_source_remove_property(tmp_path: Path) -> None:
}

config = tmp_path.joinpath("config.toml")
with config.open(mode="w") as f:
with config.open(mode="w", encoding="utf-8") as f:
f.write(tomlkit.dumps(config_data))

config_source = FileConfigSource(TOMLFile(config))
Expand All @@ -68,7 +68,7 @@ def test_file_config_source_get_property(tmp_path: Path) -> None:
}

config = tmp_path.joinpath("config.toml")
with config.open(mode="w") as f:
with config.open(mode="w", encoding="utf-8") as f:
f.write(tomlkit.dumps(config_data))

config_source = FileConfigSource(TOMLFile(config))
Expand Down
8 changes: 4 additions & 4 deletions tests/console/commands/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def test_config_migrate(
mocker.patch("poetry.locations.CONFIG_DIR", config_dir)

config_file = Path(config_dir / "config.toml")
with config_file.open("w") as fh:
with config_file.open("w", encoding="utf-8") as fh:
fh.write(current_config)

tester.execute("--migrate", inputs=proceed)
Expand All @@ -617,7 +617,7 @@ def test_config_migrate(
output = tester.io.fetch_output()
assert output.startswith(expected_output)

with config_file.open("r") as fh:
with config_file.open("r", encoding="utf-8") as fh:
assert fh.read() == expected_config


Expand All @@ -631,7 +631,7 @@ def test_config_migrate_local_config(tester: CommandTester, poetry: Poetry) -> N
prefer-active-python = false
""")

with local_config.open("w") as fh:
with local_config.open("w", encoding="utf-8") as fh:
fh.write(config_data)

tester.execute("--migrate --local", inputs="yes")
Expand All @@ -643,7 +643,7 @@ def test_config_migrate_local_config(tester: CommandTester, poetry: Poetry) -> N
use-poetry-python = true
""")

with local_config.open("r") as fh:
with local_config.open("r", encoding="utf-8") as fh:
assert fh.read() == expected_config


Expand Down
3 changes: 3 additions & 0 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def mock_clone(


class TestExecutor(Executor):
# class name begins 'Test': tell pytest that it does not contain testcases.
__test__ = False

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion tests/utils/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def test_ensure_path_file(tmp_path: Path) -> None:
with pytest.raises(ValueError):
ensure_path(path=path, is_directory=False)

path.write_text("foobar")
path.write_text("foobar", encoding="utf-8")
assert ensure_path(path=path, is_directory=False) is path


Expand Down

0 comments on commit 81f2935

Please sign in to comment.