-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
214 implement usethis tool pyproject (#325)
* Add failing tests for `usethis tool pyproject.toml` * Implement `usethis tool pyproject.toml` * Tweak tool descriptions * Fix TOML manager when deleting file * Add unit tests to tool class
- Loading branch information
1 parent
588ac7e
commit fcece11
Showing
7 changed files
with
179 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from pathlib import Path | ||
|
||
from usethis._console import tick_print | ||
from usethis._integrations.pyproject.io_ import pyproject_toml_io_manager | ||
|
||
|
||
def remove_pyproject_toml() -> None: | ||
path = Path.cwd() / "pyproject.toml" | ||
if path.exists() and path.is_file(): | ||
tick_print("Removing 'pyproject.toml' file") | ||
pyproject_toml_io_manager._opener.write_file() | ||
pyproject_toml_io_manager._opener._set = False | ||
path.unlink() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from usethis._integrations.pyproject.remove import remove_pyproject_toml | ||
from usethis._test import change_cwd | ||
|
||
|
||
class TestRemovePyprojectTOML: | ||
def test_removed(self, tmp_path: Path, capfd: pytest.CaptureFixture[str]): | ||
# Arrange | ||
pyproject_path = tmp_path / "pyproject.toml" | ||
pyproject_path.touch() | ||
|
||
# Act | ||
with change_cwd(tmp_path): | ||
remove_pyproject_toml() | ||
|
||
# Assert | ||
assert not pyproject_path.exists() | ||
out, err = capfd.readouterr() | ||
assert not err | ||
assert out == "✔ Removing 'pyproject.toml' file\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters