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:
co-authored by
pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
parent
643b30c796
commit
097806b6b1
@@ -1,4 +1,5 @@
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
@@ -10,7 +11,7 @@ from cibuildwheel.projectfiles import (
|
||||
)
|
||||
|
||||
|
||||
def test_read_setup_py_simple(tmp_path):
|
||||
def test_read_setup_py_simple(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -31,7 +32,7 @@ def test_read_setup_py_simple(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) == "1.23"
|
||||
|
||||
|
||||
def test_read_setup_py_if_main(tmp_path):
|
||||
def test_read_setup_py_if_main(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -53,7 +54,7 @@ def test_read_setup_py_if_main(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) == "1.23"
|
||||
|
||||
|
||||
def test_read_setup_py_if_main_reversed(tmp_path):
|
||||
def test_read_setup_py_if_main_reversed(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -75,7 +76,7 @@ def test_read_setup_py_if_main_reversed(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) == "1.23"
|
||||
|
||||
|
||||
def test_read_setup_py_if_invalid(tmp_path):
|
||||
def test_read_setup_py_if_invalid(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -97,7 +98,7 @@ def test_read_setup_py_if_invalid(tmp_path):
|
||||
assert not get_requires_python_str(tmp_path, {})
|
||||
|
||||
|
||||
def test_read_setup_py_full(tmp_path):
|
||||
def test_read_setup_py_full(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.py", "w", encoding="utf8") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -123,7 +124,7 @@ def test_read_setup_py_full(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) == "1.24"
|
||||
|
||||
|
||||
def test_read_setup_py_assign(tmp_path):
|
||||
def test_read_setup_py_assign(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -146,7 +147,7 @@ def test_read_setup_py_assign(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) is None
|
||||
|
||||
|
||||
def test_read_setup_py_None(tmp_path):
|
||||
def test_read_setup_py_None(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -169,7 +170,7 @@ def test_read_setup_py_None(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) is None
|
||||
|
||||
|
||||
def test_read_setup_py_empty(tmp_path):
|
||||
def test_read_setup_py_empty(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.py", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -191,7 +192,7 @@ def test_read_setup_py_empty(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) is None
|
||||
|
||||
|
||||
def test_read_setup_cfg(tmp_path):
|
||||
def test_read_setup_cfg(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.cfg", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -207,7 +208,7 @@ def test_read_setup_cfg(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) == "1.234"
|
||||
|
||||
|
||||
def test_read_setup_cfg_empty(tmp_path):
|
||||
def test_read_setup_cfg_empty(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "setup.cfg", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -223,7 +224,7 @@ def test_read_setup_cfg_empty(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, {}) is None
|
||||
|
||||
|
||||
def test_read_pyproject_toml(tmp_path):
|
||||
def test_read_pyproject_toml(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "pyproject.toml", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -242,7 +243,7 @@ def test_read_pyproject_toml(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, pyproject_toml) == "1.654"
|
||||
|
||||
|
||||
def test_read_pyproject_toml_empty(tmp_path):
|
||||
def test_read_pyproject_toml_empty(tmp_path: Path) -> None:
|
||||
with open(tmp_path / "pyproject.toml", "w") as f:
|
||||
f.write(
|
||||
dedent(
|
||||
@@ -258,7 +259,7 @@ def test_read_pyproject_toml_empty(tmp_path):
|
||||
assert get_requires_python_str(tmp_path, pyproject_toml) is None
|
||||
|
||||
|
||||
def test_read_dep_groups():
|
||||
def test_read_dep_groups() -> None:
|
||||
pyproject_toml = {"dependency-groups": {"group1": ["pkg1", "pkg2"], "group2": ["pkg3"]}}
|
||||
assert resolve_dependency_groups(pyproject_toml) == ()
|
||||
assert resolve_dependency_groups(pyproject_toml, "group1") == ("pkg1", "pkg2")
|
||||
@@ -266,11 +267,11 @@ def test_read_dep_groups():
|
||||
assert resolve_dependency_groups(pyproject_toml, "group1", "group2") == ("pkg1", "pkg2", "pkg3")
|
||||
|
||||
|
||||
def test_dep_group_no_file_error():
|
||||
def test_dep_group_no_file_error() -> None:
|
||||
with pytest.raises(FileNotFoundError, match=r"pyproject\.toml"):
|
||||
resolve_dependency_groups(None, "test")
|
||||
|
||||
|
||||
def test_dep_group_no_section_error():
|
||||
def test_dep_group_no_section_error() -> None:
|
||||
with pytest.raises(KeyError, match=r"pyproject\.toml"):
|
||||
resolve_dependency_groups({}, "test")
|
||||
|
||||
Reference in New Issue
Block a user