|
1 | 1 | from pathlib import Path |
2 | 2 |
|
3 | 3 | import pytest |
| 4 | +from typer.testing import CliRunner |
4 | 5 |
|
5 | 6 | from usethis._config import usethis_config |
| 7 | +from usethis._interface.tool import app |
6 | 8 | from usethis._subprocess import SubprocessFailedError, call_subprocess |
7 | 9 | from usethis._test import change_cwd |
8 | 10 |
|
@@ -54,3 +56,27 @@ def test_cli(self, uv_init_dir: Path): |
54 | 56 | call_subprocess(["usethis", "tool", "ruff"]) |
55 | 57 | else: |
56 | 58 | call_subprocess(["usethis", "tool", "ruff", "--offline"]) |
| 59 | + |
| 60 | + |
| 61 | +class TestPytest: |
| 62 | + def test_add(self, tmp_path: Path): |
| 63 | + # Act |
| 64 | + runner = CliRunner() |
| 65 | + with change_cwd(tmp_path): |
| 66 | + result = runner.invoke(app, ["pytest"]) |
| 67 | + |
| 68 | + # Assert |
| 69 | + assert result.exit_code == 0 |
| 70 | + |
| 71 | + |
| 72 | +@pytest.mark.benchmark |
| 73 | +def test_several_tools_add_and_remove(tmp_path: Path): |
| 74 | + runner = CliRunner() |
| 75 | + with change_cwd(tmp_path): |
| 76 | + runner.invoke(app, ["pytest"]) |
| 77 | + runner.invoke(app, ["ruff"]) |
| 78 | + runner.invoke(app, ["deptry"]) |
| 79 | + runner.invoke(app, ["pre-commit"]) |
| 80 | + runner.invoke(app, ["ruff", "--remove"]) |
| 81 | + runner.invoke(app, ["pyproject-fmt"]) |
| 82 | + runner.invoke(app, ["pytest", "--remove"]) |
0 commit comments