(app: App)
| 544 | |
| 545 | @pytest.mark.anyio |
| 546 | async def test_matcher(app: App): |
| 547 | from plugins.param.param_matcher import ( |
| 548 | FooMatcher, |
| 549 | generic_matcher, |
| 550 | generic_matcher_none, |
| 551 | last_receive, |
| 552 | legacy_matcher, |
| 553 | matcher, |
| 554 | not_legacy_matcher, |
| 555 | not_matcher, |
| 556 | pause_prompt_result, |
| 557 | postpone_matcher, |
| 558 | receive, |
| 559 | receive_prompt_result, |
| 560 | sub_matcher, |
| 561 | union_matcher, |
| 562 | ) |
| 563 | |
| 564 | fake_matcher = Matcher() |
| 565 | foo_matcher = FooMatcher() |
| 566 | |
| 567 | async with app.test_dependent(matcher, allow_types=[MatcherParam]) as ctx: |
| 568 | ctx.pass_params(matcher=fake_matcher) |
| 569 | ctx.should_return(fake_matcher) |
| 570 | |
| 571 | async with app.test_dependent(postpone_matcher, allow_types=[MatcherParam]) as ctx: |
| 572 | ctx.pass_params(matcher=fake_matcher) |
| 573 | ctx.should_return(fake_matcher) |
| 574 | |
| 575 | async with app.test_dependent(legacy_matcher, allow_types=[MatcherParam]) as ctx: |
| 576 | ctx.pass_params(matcher=fake_matcher) |
| 577 | ctx.should_return(fake_matcher) |
| 578 | |
| 579 | with pytest.raises(ValueError, match=UNKNOWN_PARAM): |
| 580 | app.test_dependent(not_legacy_matcher, allow_types=[MatcherParam]) |
| 581 | |
| 582 | async with app.test_dependent(sub_matcher, allow_types=[MatcherParam]) as ctx: |
| 583 | ctx.pass_params(matcher=foo_matcher) |
| 584 | ctx.should_return(foo_matcher) |
| 585 | |
| 586 | with pytest.raises((TypeMisMatch, BaseExceptionGroup)) as exc_info: |
| 587 | async with app.test_dependent(sub_matcher, allow_types=[MatcherParam]) as ctx: |
| 588 | ctx.pass_params(matcher=fake_matcher) |
| 589 | |
| 590 | if isinstance(exc_info.value, BaseExceptionGroup): |
| 591 | assert exc_info.group_contains(TypeMisMatch) |
| 592 | |
| 593 | async with app.test_dependent(union_matcher, allow_types=[MatcherParam]) as ctx: |
| 594 | ctx.pass_params(matcher=foo_matcher) |
| 595 | ctx.should_return(foo_matcher) |
| 596 | |
| 597 | async with app.test_dependent(generic_matcher, allow_types=[MatcherParam]) as ctx: |
| 598 | ctx.pass_params(matcher=fake_matcher) |
| 599 | ctx.should_return(fake_matcher) |
| 600 | |
| 601 | async with app.test_dependent( |
| 602 | generic_matcher_none, allow_types=[MatcherParam] |
| 603 | ) as ctx: |
nothing calls this directly
no test coverage detected