Feature: 带参数的 RegexStr() (#2499)

This commit is contained in:
Bryan不可思议
2024-01-11 11:52:07 +08:00
committed by GitHub
parent 9b09b42f97
commit 5a6f4b9e1c
3 changed files with 50 additions and 8 deletions

View File

@ -77,8 +77,13 @@ async def regex_matched(regex_matched: Match[str] = RegexMatched()) -> Match[str
return regex_matched
async def regex_str(regex_str: str = RegexStr()) -> str:
return regex_str
async def regex_str(
entire: str = RegexStr(),
type_: str = RegexStr("type"),
second: str = RegexStr(2),
groups: Tuple[str, ...] = RegexStr(1, "arg"),
) -> Tuple[str, str, str, Tuple[str, ...]]:
return entire, type_, second, groups
async def startswith(startswith: str = Startswith()) -> str:

View File

@ -361,7 +361,9 @@ async def test_state(app: App):
regex_str, allow_types=[StateParam, DependParam]
) as ctx:
ctx.pass_params(state=fake_state)
ctx.should_return("[cq:test,arg=value]")
ctx.should_return(
("[cq:test,arg=value]", "test", "arg=value", ("test", "arg=value"))
)
async with app.test_dependent(
regex_group, allow_types=[StateParam, DependParam]