File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 11import argparse
2+ import asyncio
23import re
34import sys
45import time
@@ -2120,6 +2121,29 @@ def alt_cmd(self) -> None:
21202121 }
21212122
21222123
2124+ def test_cli_app_async_method_no_existing_loop ():
2125+ class Command (BaseSettings ):
2126+ called : bool = False
2127+
2128+ async def cli_cmd (self ) -> None :
2129+ self .called = True
2130+
2131+ assert CliApp .run (Command , cli_args = []).called
2132+
2133+
2134+ def test_cli_app_async_method_with_existing_loop ():
2135+ class Command (BaseSettings ):
2136+ called : bool = False
2137+
2138+ async def cli_cmd (self ) -> None :
2139+ self .called = True
2140+
2141+ async def run_as_coro ():
2142+ return CliApp .run (Command , cli_args = [])
2143+
2144+ assert asyncio .run (run_as_coro ()).called
2145+
2146+
21232147def test_cli_app_exceptions ():
21242148 with pytest .raises (
21252149 SettingsError , match = 'Error: NotPydanticModel is not subclass of BaseModel or pydantic.dataclasses.dataclass'
You can’t perform that action at this time.
0 commit comments