templates/python: fix type annotations
This commit is contained in:
@@ -5,6 +5,6 @@ import pytest
|
|||||||
|
|
||||||
# returns a temporary directory with a fake git repo
|
# returns a temporary directory with a fake git repo
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def git_repo_path(tmp_path):
|
def git_repo_path(tmp_path: str) -> str:
|
||||||
subprocess.run(["mkdir", ".git"], cwd=tmp_path)
|
subprocess.run(["mkdir", ".git"], cwd=tmp_path)
|
||||||
return tmp_path
|
return tmp_path
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
import my_tool
|
import my_tool
|
||||||
|
|
||||||
|
|
||||||
def test_no_args(capsys):
|
def test_no_args(capsys: pytest.CaptureFixture) -> None:
|
||||||
my_tool.my_cli()
|
my_tool.my_cli()
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
assert captured.out.startswith("usage:")
|
assert captured.out.startswith("usage:")
|
||||||
|
|
||||||
|
|
||||||
def test_version(capsys, monkeypatch):
|
def test_version(capsys: pytest.CaptureFixture, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
monkeypatch.setattr(sys, "argv", ["", "--version"])
|
monkeypatch.setattr(sys, "argv", ["", "--version"])
|
||||||
my_tool.my_cli()
|
my_tool.my_cli()
|
||||||
captured = capsys.readouterr()
|
captured = capsys.readouterr()
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import my_lib
|
|||||||
|
|
||||||
|
|
||||||
# using the fixture from conftest.py
|
# using the fixture from conftest.py
|
||||||
def test_is_git_repo(git_repo_path: str):
|
def test_is_git_repo(git_repo_path: str) -> None:
|
||||||
result = my_lib.detect_git_repo(git_repo_path)
|
result = my_lib.detect_git_repo(git_repo_path)
|
||||||
assert result is True
|
assert result is True
|
||||||
|
|
||||||
|
|
||||||
# using the fixture from conftest.py
|
# using the fixture from conftest.py
|
||||||
def test_is_not_git_repo():
|
def test_is_not_git_repo() -> None:
|
||||||
with tempfile.TemporaryDirectory() as tempdir:
|
with tempfile.TemporaryDirectory() as tempdir:
|
||||||
result = my_lib.detect_git_repo(tempdir)
|
result = my_lib.detect_git_repo(tempdir)
|
||||||
assert result is False
|
assert result is False
|
||||||
|
|||||||
Reference in New Issue
Block a user