How to use start_environment method in localstack

Best Python code snippet using localstack_python

barg_environment.py

Source:barg_environment.py Github

copy

Full Screen

...52 reminder_msg.set_directive(directive)53 self.reminder(seconds_to_reminder = seconds_to_reminder,54 message = reminder_msg)55 @directive_decorator("start_environment")56 def start_environment(self, message: Message):57 """58 This method starts the environment (automatically through mTree_runner)59 and initializes agents with basic information about their values or costs. 60 Messages Handled :61 - start_environment62 sender: None 63 """64 self.set_reminder("env_end_period", self.state['period_length'])65 self.send_message("start_bargaining", "barg_institution.BargInstitution")66 @directive_decorator("contract")67 def contract(self, message: Message):68 """69 Receives contract tuple from Institution.70 payload: (buyer, seller, price)...

Full Screen

Full Screen

pytest_plugin.py

Source:pytest_plugin.py Github

copy

Full Screen

1import pathlib2import typing3import pytest4from . import control5from . import utils6class Hookspec:7 def pytest_service_register(self, register_service):8 """Register testsuite environment service."""9class TestsuiteEnvironmentPlugin:10 _env: typing.Optional[control.TestsuiteEnvironment]11 def __init__(self):12 self._env = None13 def ensure_started(self, service_name, **kwargs):14 if self._env:15 self._env.ensure_started(service_name, **kwargs)16 def pytest_sessionstart(self, session):17 start_environment = session.config.option.start_environment18 if start_environment == 'no':19 return20 if hasattr(session.config, 'workerinput'):21 worker_id = session.config.workerinput['workerid']22 elif session.config.pluginmanager.getplugin('dsession'):23 return24 else:25 worker_id = control.DEFAULT_WORKER_ID26 config = control.load_environment_config(27 env_dir=session.config.option.env_dir,28 worker_id=worker_id,29 reuse_services=start_environment == 'auto',30 verbose=session.config.option.verbose,31 )32 self._env = control.TestsuiteEnvironment(config)33 def register_service(service_name, factory=None):34 def decorator(factory):35 self._env.register_service(service_name, factory)36 if factory is None:37 return decorator38 return decorator(factory)39 session.config.pluginmanager.hook.pytest_service_register(40 register_service=register_service,41 )42 def pytest_sessionfinish(self, session):43 if self._env:44 self._env.close()45 def pytest_addhooks(self, pluginmanager):46 pluginmanager.add_hookspecs(Hookspec)47 def pytest_report_header(self, config):48 headers = []49 if self._env:50 if self._env.config.reuse_services:51 kind = 'auto'52 else:53 kind = 'new'54 headers.append(55 f'testsuite env: {kind}, dir: {self._env.config.env_dir}',56 )57 else:58 headers.append('testsuite env: external')59 return headers60def pytest_addoption(parser):61 group = parser.getgroup('env', 'Testsuite environment')62 group.addoption(63 '--env-dir',64 default=None,65 type=pathlib.Path,66 help='Path environment data directry.',67 )68 group.addoption(69 '--start-environment', choices=['yes', 'no', 'auto'], default='yes',70 )71 group.addoption(72 '--no-env',73 action='store_const',74 const='no',75 dest='start_environment',76 help='Use existing environment, do not start new',77 )78 group.addoption(79 '--auto-env',80 action='store_const',81 const='auto',82 dest='start_environment',83 help='If present use existing environment, otherwise start new',84 )85 group.addoption(86 '--start-env',87 action='store_const',88 const='yes',89 dest='start_environment',90 help='Start new environment',91 )92def pytest_configure(config):93 utils.ensure_non_root_user()94 config.pluginmanager.register(95 TestsuiteEnvironmentPlugin(), 'testsuite_environment',96 )97@pytest.fixture(scope='session')98def ensure_service_started(pytestconfig):99 env: TestsuiteEnvironmentPlugin100 env = pytestconfig.pluginmanager.get_plugin('testsuite_environment')...

Full Screen

Full Screen

md_envbox_augment.py

Source:md_envbox_augment.py Github

copy

Full Screen

1import sys2import os3try:4 file = sys.argv[1]5except:6 sys.exit("ERROR: Please input a file to eat")7with open ("../formatting/tex_macros.tex", "r") as f:8 tex_macros = f.read()9environment_types = ["thm", "rmk", "prop", "ex", "cor", "lem", "clm", "defn", "pf", "quote"]10long_name = {11 "thm": "Theorem",12 "rmk": "Remark",13 "prop": "Proposition",14 "ex": "Example",15 "cor": "Corollary",16 "clm": "Claim",17 "lem": "Lemma",18 "defn": "Definition",19 "pf": "Proof", 20 "quote": "Quote"21}22looking_for_closure = False23start_environment = ""24out_text = ""25with open(file, "r") as f:26 for row in f:27 row_handled = False28 if not looking_for_closure:29 for env_type in environment_types:30 if row.strip() == f"begin {env_type}":31 looking_for_closure = True32 start_environment = env_type33 34 if start_environment == "quote":35 out_text += "---\n\n"36 else:37 out_text += f'<div class="{start_environment} envbox">**{long_name[start_environment]}.**\n'38 row_handled = True39 break40 elif looking_for_closure:41 if row.strip() == f"end {start_environment}":42 looking_for_closure = False43 if start_environment == "quote":44 out_text += "\n---\n"45 else:46 out_text += f"</div>\n"47 unclosed_stack = []48 start_environment = ""49 row_handled = True50 if not row_handled:51 if looking_for_closure and start_environment == "quote":52 out_text += "> " + row.strip() + " \n"53 else:54 out_text += row55if looking_for_closure:56 sys.exit("ERROR: no closure!")57path_start, path_end = os.path.split(file.replace(".md", ".aug.md"))58out_path = os.path.join(path_start, "data", path_end)59with open(out_path, 'w') as f:60 f.write(tex_macros)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful