Best Python code snippet using localstack_python
conftest.py
Source:conftest.py
...9from localstack.utils import net10from localstack.utils.sync import poll_condition11LOG = logging.getLogger(__name__)12@pytest.fixture()13def serve_asgi_app():14 _servers = []15 def _create(16 app: ASGI3Framework, config: Config = None, event_loop: AbstractEventLoop = None17 ) -> HypercornServer:18 if not config:19 config = Config()20 config.bind = f"localhost:{net.get_free_tcp_port()}"21 srv = HypercornServer(app, config, loop=event_loop)22 _servers.append(srv)23 srv.start()24 assert srv.wait_is_up(timeout=10), "gave up waiting for server to start up"25 return srv26 yield _create27 for server in _servers:28 server.shutdown()29 assert poll_condition(30 lambda: not server.is_up(), timeout=1031 ), "gave up waiting for server to shut down"32@pytest.fixture()33def serve_asgi_adapter(serve_asgi_app):34 def _create(wsgi_app):35 loop = asyncio.new_event_loop()36 return serve_asgi_app(37 ASGIAdapter(38 wsgi_app,39 event_loop=loop,40 ),41 event_loop=loop,42 )...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!