Skip to content

Commit 912fef9

Browse files
committed
test: count a missing optional library as a refusal on the capability facade walk
1 parent 8cd3827 commit 912fef9

1 file changed

Lines changed: 24 additions & 15 deletions

File tree

‎tests/test_capable_protocol.py‎

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -857,11 +857,12 @@ def _resolved(arguments: tuple[object, ...], value: object) -> tuple[object, ...
857857
return tuple(one.read(value) if isinstance(one, _Relative) else one for one in arguments)
858858

859859

860-
_REFUSALS = (AssertionFailure, TypeError, ValueError, LookupError, OSError)
860+
_REFUSALS = (AssertionFailure, TypeError, ValueError, LookupError, OSError, ImportError)
861861
"""What asking answers with instead of a builder: a failed verdict, a refusal, a lookup the value's own
862-
`__getitem__` stops, and a path that is not there. Anything else fails, which is how `UnorderableError`
863-
surfaced. Judged by type and not by where it was raised, so a bug raising one of these reads as a refusal:
864-
the claim here is what a builder hands back, not that nothing crashes."""
862+
`__getitem__` stops, a path that is not there, and an optional library this cell does not install.
863+
Anything else fails, which is how `UnorderableError` surfaced. Judged by type and not by where it was
864+
raised, so a bug raising one of these reads as a refusal: the claim here is what a builder hands back, not
865+
that nothing crashes."""
865866

866867
_EXPECTATION_VIEWS = frozenset({"_ExpectedRaiseAssertion", "_ExpectedWarningAssertion", "_ExpectedCompletionAssertion"})
867868
"""Views over the callable itself, `value` being the callable on `_CallableAssertion`."""
@@ -995,18 +996,26 @@ def test_the_floor_reaches_every_name_the_property_holds() -> None:
995996
"""The floor counts answers, not attempts, so a name nothing on it answers is not held rather than held vacuously.
996997
997998
Checked in both directions: a name the floor starts to reach has to move into the property, and one it
998-
stops reaching has to be excused here by name.
999+
stops reaching has to be excused here by name. A name needing a library this cell lacks is left out of
1000+
both sides, so the record reads the same wherever it runs: the array pair has no numpy on 3.15.
9991001
"""
1000-
reached = {
1001-
name
1002-
for subject in _FLOOR
1003-
for name in _PROMISED
1004-
for arguments in _ASKED_WITH
1005-
if _asked(name, subject, arguments) is not _REFUSED
1006-
}
1007-
assert_that(sorted(set(_PROMISED) - reached)).described_as("promised and never answered on the floor").is_equal_to(
1008-
sorted(_NOT_HELD)
1009-
)
1002+
reached: set[str] = set()
1003+
unavailable: set[str] = set()
1004+
for subject in _FLOOR:
1005+
for name in _PROMISED:
1006+
for arguments in _ASKED_WITH:
1007+
try:
1008+
getattr(assert_that(subject), name)(*_resolved(arguments, subject))
1009+
# a refusal per question, and the next question may still be answered
1010+
except ImportError: # noqa: PERF203
1011+
unavailable.add(name)
1012+
except _REFUSALS:
1013+
continue
1014+
else:
1015+
reached.add(name)
1016+
assert_that(sorted(set(_PROMISED) - reached - unavailable)).described_as(
1017+
"promised and never answered on the floor"
1018+
).is_equal_to(sorted(_NOT_HELD - unavailable))
10101019

10111020

10121021
def test_the_claims_are_the_shapes_the_umbrella_is_bound_to() -> None:

0 commit comments

Comments
 (0)