Best Python code snippet using avocado_python
vm_discover_test.py
Source: vm_discover_test.py
1#!/usr/bin/env python2import unittest3from bardolph.controller import light_set4from bardolph.fakes import fake_lifx5from bardolph.vm.call_stack import CallStack6from bardolph.vm.machine import Registers7from bardolph.vm.vm_codes import Operand8from bardolph.vm.vm_discover import VmDiscover9from tests import test_module10class VmDiscoverTest(unittest.TestCase):11 def setUp(self):12 test_module.configure()13 self._make_light_set()14 self._reg = Registers()15 self._discover = VmDiscover(CallStack(), self._reg)16 def test_all_lights(self):17 self._reg.operand = Operand.LIGHT18 self._discover.disc()19 for name in ('light_02', 'light_01', 'light_00'):20 self._assert_and_next(name)21 self.assertEqual(self._reg.result, Operand.NULL)22 def test_all_lights_fwd(self):23 self._reg.operand = Operand.LIGHT24 self._reg.disc_forward = True25 self._discover.disc()26 for name in ('light_00', 'light_01', 'light_02'):27 self._assert_and_next(name)28 self.assertEqual(self._reg.result, Operand.NULL)29 def test_all_groups(self):30 self._reg.operand = Operand.GROUP31 self._discover.disc()32 self._assert_and_next('x')33 self._assert_and_next('group')34 self.assertEqual(self._reg.result, Operand.NULL)35 def test_all_groups_fwd(self):36 self._reg.operand = Operand.GROUP37 self._reg.disc_forward = True38 self._discover.disc()39 self._assert_and_next('group')40 self._assert_and_next('x')41 self.assertEqual(self._reg.result, Operand.NULL)42 def test_all_locations(self):43 self._reg.operand = Operand.LOCATION44 self._discover.disc()45 self._assert_and_next('y')46 self._assert_and_next('loc')47 self.assertEqual(self._reg.result, Operand.NULL)48 def test_all_locations_fwd(self):49 self._reg.operand = Operand.LOCATION50 self._reg.disc_forward = True51 self._discover.disc()52 self._assert_and_next('loc')53 self._assert_and_next('y')54 self.assertEqual(self._reg.result, Operand.NULL)55 def test_group_membership(self):56 self._reg.operand = Operand.GROUP57 self._discover.discm('group')58 self._assert_and_nextm('group', 'light_02')59 self._assert_and_nextm('group', 'light_00')60 self.assertEqual(self._reg.result, Operand.NULL)61 def test_group_membership_fwd(self):62 self._reg.operand = Operand.GROUP63 self._reg.disc_forward = True64 self._discover.discm('group')65 self._assert_and_nextm('group', 'light_00')66 self._assert_and_nextm('group', 'light_02')67 self.assertEqual(self._reg.result, Operand.NULL)68 def test_location_membership(self):69 self._reg.operand = Operand.LOCATION70 self._discover.discm('loc')71 self._assert_and_nextm('loc', 'light_02')72 self._assert_and_nextm('loc', 'light_00')73 self.assertEqual(self._reg.result, Operand.NULL)74 def test_location_membership_fwd(self):75 self._reg.operand = Operand.LOCATION76 self._reg.disc_forward = True77 self._discover.discm('loc')78 self._assert_and_nextm('loc', 'light_00')79 self._assert_and_nextm('loc', 'light_02')80 self.assertEqual(self._reg.result, Operand.NULL)81 @staticmethod82 def _make_light_set():83 color = [1, 2, 3, 4]84 fake_lifx.using([85 ('light_01', 'x', 'y', color, False),86 ('light_02', 'group', 'loc', color, False),87 ('light_00', 'group', 'loc', color, False)88 ]).configure()89 light_set.configure()90 def _assert_and_next(self, name):91 self.assertEqual(self._reg.result, name)92 self._discover.dnext(name)93 def _assert_and_nextm(self, lights, name):94 self.assertEqual(self._reg.result, name)95 self._discover.dnextm(lights, name)96if __name__ == '__main__':...
discovery.py
Source: discovery.py
...9 .. seealso::10 The asynchronous equivalent11 :py:func:`pupil_labs.realtime_api.discovery.discover_devices`12 """13 async def _discover():14 async with AsyncNetwork() as network:15 await asyncio.sleep(search_duration_seconds)16 return network.devices17 return [Device.from_discovered_device(dev) for dev in asyncio.run(_discover())]18def discover_one_device(19 max_search_duration_seconds: T.Optional[float] = 10.0,20) -> T.Optional[Device]:21 """Return the first device that could be found in the given search duration.22 .. seealso::23 The asynchronous equivalent24 :py:func:`pupil_labs.realtime_api.discovery.Network.wait_for_new_device`25 """26 async def _discover():27 async with AsyncNetwork() as network:28 return await network.wait_for_new_device(max_search_duration_seconds)29 device = asyncio.run(_discover())...
__init__.py
Source: __init__.py
...15 # Parse command line arguments16 args = utils.parse_args(REQUIRED_CONFIG_KEYS)17 # If discover flag was passed, run discovery mode and dump output to stdout18 if args.discover:19 catalog = _discover(args.config)20 catalog.dump()21 # Otherwise run in sync mode22 else:23 if args.catalog:24 catalog = args.catalog25 else:26 catalog = _discover(args.config)27 sync(args.config, args.state, catalog)28if __name__ == "__main__":...
Check out the latest blogs from LambdaTest on this topic:
Hola Testers! Hope you all had a great Thanksgiving weekend! To make this time more memorable, we at LambdaTest have something to offer you as a token of appreciation.
In addition to the four values, the Agile Manifesto contains twelve principles that are used as guides for all methodologies included under the Agile movement, such as XP, Scrum, and Kanban.
JavaScript is one of the most widely used programming languages. This popularity invites a lot of JavaScript development and testing frameworks to ease the process of working with it. As a result, numerous JavaScript testing frameworks can be used to perform unit testing.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
The rapid shift in the use of technology has impacted testing and quality assurance significantly, especially around the cloud adoption of agile development methodologies. With this, the increasing importance of quality and automation testing has risen enough to deliver quality work.
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!!