Skip to content

Commit 462dcc7

Browse files
committed
Specify str type when using pytest CaptureFixture
1 parent 8be87d9 commit 462dcc7

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

tests/test_venv_clear.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
@pytest.mark.order(after="test_venv_install.py::test_venv_install")
9-
def test_venv_clear(tmp_path: Path, capfd: pytest.CaptureFixture):
9+
def test_venv_clear(tmp_path: Path, capfd: pytest.CaptureFixture[str]):
1010
"""Checks that we can clear installed packages in an environment after installing them"""
1111
run_command(commands=["venv install --skip-lock", "venv clear"], activated=True, cwd=tmp_path)
1212

tests/test_venv_deactivate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def test_venv_deactivate(tmp_path: Path):
1111
run_command("venv deactivate", activated=True, cwd=tmp_path)
1212

1313

14-
def test_venv_deactivate_noop(tmp_path: Path, capfd: pytest.CaptureFixture):
14+
def test_venv_deactivate_noop(tmp_path: Path, capfd: pytest.CaptureFixture[str]):
1515
"""Checks that trying to deactivate an environment that is not activated does nothing"""
1616
run_command("venv deactivate", cwd=tmp_path)
1717

tests/test_venv_help.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
@pytest.mark.parametrize("arg", ["", "-h", "--help"])
9-
def test_venv_help(arg: str, tmp_path: Path, capfd: pytest.CaptureFixture):
9+
def test_venv_help(arg: str, tmp_path: Path, capfd: pytest.CaptureFixture[str]):
1010
"""Checks that we can get the help menu for the main 'venv' command"""
1111
run_command(f"venv {arg}", cwd=tmp_path)
1212

tests/test_venv_install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_venv_install_requirements(
3737
requirements_stem: RequirementsStem,
3838
use_file_name: bool,
3939
tmp_path: Path,
40-
capfd: pytest.CaptureFixture,
40+
capfd: pytest.CaptureFixture[str],
4141
):
4242
write_files(files=files, dir=tmp_path)
4343

@@ -56,7 +56,7 @@ def test_venv_install_requirements(
5656
)
5757

5858
# Check pip install log output
59-
output: str = capfd.readouterr().out
59+
output = capfd.readouterr().out
6060
assert f"Installing requirements from {requirements_stem.value}.txt" in output
6161

6262
installed_line = [line for line in output.splitlines() if line.startswith("Successfully installed")][0]

tests/test_venv_internals.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_venv_check_install_requirements_file(filename: str, expected: bool):
5757
run_command(command)
5858

5959

60-
def test_venv_check_install_requirements_file_quiet(capfd: pytest.CaptureFixture):
60+
def test_venv_check_install_requirements_file_quiet(capfd: pytest.CaptureFixture[str]):
6161
"""Check that 'venv::_check_install_requirements_file' can raise silently if called with -q"""
6262
# Call command with bad argument, not silenced
6363
with pytest.raises(subprocess.CalledProcessError):
@@ -109,7 +109,7 @@ def test_venv_check_lock_requirements_file(filename: str, expected_success: bool
109109
run_command(command)
110110

111111

112-
def test_venv_check_lock_requirements_file_quiet(capfd: pytest.CaptureFixture):
112+
def test_venv_check_lock_requirements_file_quiet(capfd: pytest.CaptureFixture[str]):
113113
"""Check that 'venv::_check_lock_requirements_file' can raise silently if called with -q"""
114114
# Call command with bad argument, not silenced
115115
with pytest.raises(subprocess.CalledProcessError):
@@ -136,7 +136,7 @@ def test_venv_check_lock_requirements_file_quiet(capfd: pytest.CaptureFixture):
136136
("requirements/requirements.lock", "requirements/requirements.lock"),
137137
],
138138
)
139-
def test_venv_get_lock_from_requirements(filename: str, expected: str, capfd: pytest.CaptureFixture):
139+
def test_venv_get_lock_from_requirements(filename: str, expected: str, capfd: pytest.CaptureFixture[str]):
140140
"""Check that 'venv::_get_lock_from_requirements' works as expected"""
141141
run_command(f'venv::_get_lock_from_requirements "{filename}"')
142142
result = capfd.readouterr().out.strip()
@@ -155,7 +155,7 @@ def test_venv_get_lock_from_requirements(filename: str, expected: str, capfd: py
155155
("requirements/requirements.txt", "requirements/requirements.txt"),
156156
],
157157
)
158-
def test_venv_get_requirements_from_lock(filename: str, expected: str, capfd: pytest.CaptureFixture):
158+
def test_venv_get_requirements_from_lock(filename: str, expected: str, capfd: pytest.CaptureFixture[str]):
159159
"""Check that 'venv::_get_requirements_from_lock' works as expected"""
160160
run_command(f'venv::_get_requirements_from_lock "{filename}"')
161161
result = capfd.readouterr().out.strip()

tests/test_venv_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_venv_lock_raises(lock_arg: str, tmp_path: Path):
6565
"test_venv_fill_credentials.py::test_venv_fill_credentials",
6666
]
6767
)
68-
def test_venv_lock_echo(tmp_path: Path, capfd: pytest.CaptureFixture):
68+
def test_venv_lock_echo(tmp_path: Path, capfd: pytest.CaptureFixture[str]):
6969
"""Checks that 'venv lock' echoes a message when executed"""
7070
run_command("venv lock", activated=True, cwd=tmp_path)
7171

tests/test_venv_raise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@pytest.mark.order("first")
99
@pytest.mark.parametrize("message", ["", '"This is an error"'])
10-
def test_venv_raise(message: str, capfd: pytest.CaptureFixture):
10+
def test_venv_raise(message: str, capfd: pytest.CaptureFixture[str]):
1111
with pytest.raises(subprocess.CalledProcessError):
1212
run_command(f"venv::raise {message}")
1313

tests/test_venv_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
@pytest.mark.parametrize("arg", ["-V", "--version"])
11-
def test_venv_version(arg: str, capfd: pytest.CaptureFixture):
11+
def test_venv_version(arg: str, capfd: pytest.CaptureFixture[str]):
1212
"""Checks that we can show the version number, and that the version number
1313
complies with the required pattern"""
1414
run_command(f"venv {arg}")

0 commit comments

Comments
 (0)