Type the fake host modules in the tests so mypy passes on them
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ff5046993
commit
0448a34ddb
2 files changed
+9
-7
No files matched your search
@@ -120,7 +120,7 @@ def test_the_registry_refuses_a_module_missing_a_required_name(
|
||||
|
||||
|
||||
def test_the_contract_check_names_each_problem() -> None:
|
||||
module = types.ModuleType("odd")
|
||||
module: Any = types.ModuleType("odd")
|
||||
module.NAME, module.LABEL, module.PATTERNS = "other", "", ("(",)
|
||||
module.slug_ok = module.allowed = module.careers_url = lambda slug: ""
|
||||
module.page = lambda get, slug, cursor: None
|
||||
@@ -246,7 +246,7 @@ def _fake_host(*, detail: Callable[..., Any] | None = None,
|
||||
"""A host `fake` whose feed is a JSON list of ids, each role with a
|
||||
teaser for a description, and, with `detail`, a per-role page; with
|
||||
`robots`, its listing is the page robots.txt must allow."""
|
||||
module = types.ModuleType("fake")
|
||||
module: Any = types.ModuleType("fake")
|
||||
module.NAME, module.LABEL, module.PATTERNS = "fake", "Fake", ()
|
||||
module.slug_ok = lambda slug: slug.isalnum()
|
||||
module.allowed = lambda slug: lambda h: h == "jobs.fake.example"
|
||||
@@ -293,7 +293,7 @@ def web(monkeypatch: pytest.MonkeyPatch) -> dict[str, Any]:
|
||||
|
||||
|
||||
def _run(monkeypatch: pytest.MonkeyPatch, module: types.ModuleType,
|
||||
state: dict[str, str] | None = None) -> tuple[list[Any], dict[str, str]]:
|
||||
state: dict[str, str] | None = None) -> tuple[list[Any], Any]:
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", module)
|
||||
source = ats.ATSSource({"boards": [{"url": "fake:acme", "label": "Acme"}], "run": "r"})
|
||||
if state is not None:
|
||||
@@ -500,7 +500,7 @@ def test_detail_fills_only_the_fields_a_later_pull_keeps(
|
||||
|
||||
def _paged_host() -> types.ModuleType:
|
||||
"""A host `fake` that pages its listing, one id a page, and has `detail`."""
|
||||
module = _fake_host(detail=_detail)
|
||||
module: Any = _fake_host(detail=_detail)
|
||||
del module.feed_url, module.parse
|
||||
|
||||
def page(get: Any, slug: str, cursor: Any) -> tuple[Any, list[dict[str, Any]], Any, Any]:
|
||||
@@ -552,7 +552,7 @@ def test_a_pull_stopped_half_way_through_a_board_keeps_no_detail_ids(
|
||||
web["answers"].update({f"{base}/list": b'["1", "2"]', f"{base}/1": b"one", f"{base}/2": b"two"})
|
||||
monkeypatch.setitem(atshosts.HOSTS, "fake", _fake_host(detail=_detail))
|
||||
source = ats.ATSSource({"boards": [{"url": "fake:acme", "label": "Acme"}], "run": "r"})
|
||||
roles = source.fetch()
|
||||
roles: Any = source.fetch() # a generator, which `close` stops
|
||||
assert next(roles).body == "one"
|
||||
roles.close()
|
||||
assert "ats:detailed:fake:acme" not in source.state
|
||||
|
||||
Reference in new issue
Block a user