Best Python code snippet using localstack_python
conftest.py
Source:conftest.py
...30 return driver313233@pytest.fixture(scope='module')34def get_environment():35 if getenv('environment') is None:36 environ['environment'] = 'test'37 return getenv('environment')383940@pytest.fixture(scope='function')41def google_page(browser):42 attach(config.driver.get_screenshot_as_png(), attachment_type=AttachmentType.PNG)43 return GooglePage(browser)444546@pytest.fixture(scope='function')47def get_langs_ids(get_environment):48 lang = Language()
...
sma_agent.py
Source:sma_agent.py
...37 def get_dx(self):38 return self._dx39 def get_dy(self):40 return self._dy41 def get_environment(self):42 return self.environnenment43 def set_environment(self, env):44 self.environnenment = env45 def make_random_move(self):46 self._dx += (randint(-1, 1) * self.get_environment().coef_deplacement)47 self._dy += (randint(-1, 1) * self.get_environment().coef_deplacement)48 if self._dx < self.get_environment().xmin:49 self._dx = self.get_environment().xmin50 if self._dx > self.get_environment().xmax:51 self._dx = self.get_environment().xmax52 if self._dy < self.get_environment().ymin:53 self._dy = self.get_environment().ymin54 if self._dy > self.get_environment().ymax:55 self._dy = self.get_environment().ymax56 def on_perceive(self, agents) -> None:57 self.reset_neighbour()58 for agent in agents:59 length = sqrt(pow(self._dx - agent.get_dx(), 2) +60 pow(self._dy - agent.get_dy(), 2))61 if length < self.get_environment().field_of_view and self != agent:62 self.add_neighbour(agent)63 self.find_the_majority_color()64 def on_act(self) -> None:65 # couleur66 if self.majority_color != self._color:67 self._color = self.majority_color68 elif randint(1, 1000) <= 4:69 self._color = SimpleAgent.int_to_color.get(randint(0, 4))70 # déplacement71 self.make_random_move()72 def find_the_majority_color(self) -> Color:73 couleurs_voisin = [0, 0, 0, 0, 0]74 for agent in self.get_neighbour():75 couleurs_voisin[SimpleAgent.color_to_int.get(...
antExample3.py
Source:antExample3.py
...30 def on_perceive(self) -> None:31 self.reset_neighbour()32 for agent in self.get_amas().get_agents():33 length = sqrt(pow(self._dx - agent.get_dx(), 2) + pow(self._dy - agent.get_dy(), 2))34 if length < self.get_environment().field_of_view:35 self.add_neighbour(agent)36 def on_act(self) -> None:37 # couleur38 if self._color == Color.BLACK:39 color = {40 1: Color.BLUE,41 2: Color.BLACK,42 3: Color.RED,43 4: Color.YELLOW,44 5: Color.GREEN45 }46 if randint(1, 100) <= 2:47 self._color = color.get(randint(1, 5))48 # déplacement49 self._dx += (randint(-1, 1) * self.get_environment().coef_deplacement)50 self._dy += (randint(-1, 1) * self.get_environment().coef_deplacement)51 if self._dx < self.get_environment().xmin:52 self._dx = self.get_environment().xmin53 if self._dx > self.get_environment().xmax:54 self._dx = self.get_environment().xmax55 if self._dy < self.get_environment().ymin:56 self._dy = self.get_environment().ymin57 if self._dy > self.get_environment().ymax:58 self._dy = self.get_environment().ymax59 if self._color != Color.BLACK:60 for neighbor in self.get_neighbour():...
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!!