Skip to content

Commit

Permalink
tests: Type capfd instead of documenting by a comment
Browse files Browse the repository at this point in the history
The result is similar: the reader knows where `capfd` comes from, and
they can benefit from the typing.
  • Loading branch information
dbaty committed Apr 12, 2024
1 parent 8e28243 commit 6678194
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/test_check_branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_get_repository_info():
host, owner, repo_name = branches.get_repository_info('.')


def test_output_fresh_branches(capfd): # capfd is a pytest fixture
def test_output_fresh_branches(capfd: pytest.CaptureFixture):
config = branches.Config(
path=base.TEST_DIR_PATH.parent,
max_age=9999,
Expand All @@ -71,7 +71,7 @@ def test_output_fresh_branches(capfd): # capfd is a pytest fixture
assert stdout[0] == "OK: All branches are fresh."


def test_output_old_branches(capfd): # capfd is a pytest fixture
def test_output_old_branches(capfd: pytest.CaptureFixture):
with pytest.raises(TypeError):
config = branches.Config(host_owner='Polyconseil') # pylint: disable=unexpected-keyword-arg

Expand Down
4 changes: 2 additions & 2 deletions tests/test_check_fixmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


@mock.patch("check_oldies.annotations.get_line_blame", base.fake_get_line_blame)
def test_output_when_all_annotations_are_fresh(capfd): # capfd is a pytest fixture
def test_output_when_all_annotations_are_fresh(capfd: pytest.CaptureFixture):
config = annotations.Config(
path=base.TEST_DIR_PATH / "data/project1",
max_age=9999,
Expand All @@ -39,7 +39,7 @@ def test_output_when_all_annotations_are_fresh(capfd): # capfd is a pytest fixt
assert stdout == expected


def test_output_when_no_annotations(capfd): # capfd is a pytest fixture
def test_output_when_no_annotations(capfd: pytest.CaptureFixture):
config = annotations.Config(path=base.TEST_DIR_PATH / "data/project2")

with mock.patch("check_oldies.configuration.get_config", return_value=config):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_check_future_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


@mock.patch("check_oldies.annotations.get_line_blame", base.fake_get_line_blame)
def test_output_with_orphan_future_tags(capfd): # capfd is a pytest fixture
def test_output_with_orphan_future_tags(capfd: pytest.CaptureFixture):
config = annotations.Config(
path=base.TEST_DIR_PATH / "data/project3",
colorize_errors=False,
Expand All @@ -35,7 +35,7 @@ def test_output_with_orphan_future_tags(capfd): # capfd is a pytest fixture


@mock.patch("check_oldies.annotations.get_line_blame", base.fake_get_line_blame)
def test_output_with_ignored_annotations_orphans_future_tags(capfd): # capfd is a pytest fixture
def test_output_with_ignored_annotations_orphans_future_tags(capfd: pytest.CaptureFixture):
config = annotations.Config(
path=base.TEST_DIR_PATH / "data/project6",
colorize_errors=False,
Expand Down
4 changes: 3 additions & 1 deletion tests/test_forget_me_not.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import os
from unittest import mock

import pytest

from check_oldies import forget_me_not

from . import base
Expand All @@ -20,7 +22,7 @@ def in_working_directory(path):


@mock.patch("check_oldies.annotations.get_line_blame", base.fake_get_line_blame)
def test_forget_me_not(capfd): # capfd is a pytest fixture
def test_forget_me_not(capfd: pytest.CaptureFixture):
with in_working_directory(base.TEST_DIR_PATH / 'data'):
forget_me_not.main(argv=[])
captured = capfd.readouterr()
Expand Down

0 comments on commit 6678194

Please sign in to comment.