tests: fully type the test suite (#2794)

* tests: fully type the test suite

* chore: require more typing

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Henry Schreiner
2026-04-01 15:23:02 +01:00
committed by GitHub
co-authored by pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
parent 643b30c796
commit 097806b6b1
58 changed files with 627 additions and 339 deletions
+10 -10
View File
@@ -43,11 +43,11 @@ def path_contains(parent, child):
class TestSpam(TestCase):
def test_filter(self):
def test_filter(self) -> None:
self.assertEqual(0, spam.filter("spam"))
self.assertNotEqual(0, spam.filter("ham"))
def test_virtualenv(self):
def test_virtualenv(self) -> None:
# sys.prefix is different from sys.base_prefix when running a virtualenv
# See https://docs.python.org/3/library/venv.html, which virtualenv seems
# to honor in recent releases
@@ -58,7 +58,7 @@ class TestSpam(TestCase):
self.assertTrue(path_contains(sys.prefix, spam.__file__))
self.assertIn("VIRTUAL_ENV", os.environ)
def test_uname(self):
def test_uname(self) -> None:
if platform.system() == "Windows":
return
# if we're running in 32-bit Python, check that the machine is i686.
@@ -69,7 +69,7 @@ class TestSpam(TestCase):
'''
def test(tmp_path):
def test(tmp_path: Path) -> None:
project_dir = tmp_path / "project"
project_with_a_test.generate(project_dir)
@@ -90,7 +90,7 @@ def test(tmp_path):
assert set(actual_wheels) == set(expected_wheels)
def test_extras_require(tmp_path):
def test_extras_require(tmp_path: Path) -> None:
project_dir = tmp_path / "project"
project_with_a_test.generate(project_dir)
@@ -112,7 +112,7 @@ def test_extras_require(tmp_path):
assert set(actual_wheels) == set(expected_wheels)
def test_dependency_groups(tmp_path):
def test_dependency_groups(tmp_path: Path) -> None:
group_project = project_with_a_test.copy()
group_project.files["pyproject.toml"] = inspect.cleandoc("""
[build-system]
@@ -149,12 +149,12 @@ project_with_a_failing_test.files["test/spam_test.py"] = r"""
from unittest import TestCase
class TestSpam(TestCase):
def test_something(self):
def test_something(self) -> None:
self.fail('this test is supposed to fail')
"""
def test_failing_test(tmp_path):
def test_failing_test(tmp_path: Path) -> None:
"""Ensure a failing test causes cibuildwheel to error out and exit"""
project_dir = tmp_path / "project"
output_dir = tmp_path / "output"
@@ -215,7 +215,7 @@ def test_bare_pytest_invocation(
)
def test_test_sources(tmp_path):
def test_test_sources(tmp_path: Path) -> None:
project_dir = tmp_path / "project"
project_with_a_test.generate(project_dir)
@@ -235,7 +235,7 @@ def test_test_sources(tmp_path):
assert set(actual_wheels) == set(expected_wheels)
def test_test_environment(tmp_path):
def test_test_environment(tmp_path: Path) -> None:
project_dir = tmp_path / "project"
test_projects.new_c_project().generate(project_dir)