Python behave.given() Examples
The following are 17
code examples of behave.given().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
behave
, or try the search function
.
Example #1
Source File: common.py From pylink with Apache License 2.0 | 6 votes |
def step_connect_device(context, device): """Tries to connect to the given. Args: context (Context): the ``Context`` instance device (str): name of the devie to connect to Returns: ``None`` """ try: jlink = context.jlink jlink.connect(str(device)) jlink.set_reset_strategy(pylink.JLinkResetStrategyCortexM3.NORMAL) except pylink.JLinkException as e: if e.code == pylink.JLinkGlobalErrors.VCC_FAILURE: context.scenario.skip(reason='Target is not powered.') elif e.code == pylink.JLinkGlobalErrors.NO_CPU_FOUND: context.scenario.skip(reason='Target core not found.')
Example #2
Source File: debug.py From pylink with Apache License 2.0 | 6 votes |
def step_set_breakpoint(context, addr): """Sets a breakpoint at the given address. Args: context (Context): the ``Context`` instance addr (str): the address to set the breakpoint at Returns: ``None`` Raises: TypeError: if the given address cannot be converted to an int. """ addr = int(addr, 0) context.handle = context.jlink.breakpoint_set(addr, thumb=True) assert context.jlink.breakpoint_find(addr) == context.handle bp = context.jlink.breakpoint_info(context.handle) assert bp.Addr == addr
Example #3
Source File: debug.py From pylink with Apache License 2.0 | 6 votes |
def step_set_watchpoint(context, addr, data): """Sets a watchpoint at the given address for the given data value. Args: context (Context): the ``Context`` instance addr (str): the address the watchpoint should be set at data (str): the data value to trigger the watchpoint on Returns: ``None`` Raises: TypeError: if the given address or data cannot be converted to an int. """ addr = int(addr, 0) data = int(data, 0) context.handle = context.jlink.watchpoint_set(addr, data=data) wp = context.jlink.watchpoint_info(context.handle) assert wp.Addr == addr assert wp.Handle == context.handle assert wp.Data == data
Example #4
Source File: wrappers.py From sismic with GNU Lesser General Public License v3.0 | 6 votes |
def map_action(step_text: str, existing_step_or_steps: Union[str, List[str]]) -> None: """ Map new "given"/"when" steps to one or many existing one(s). Parameters are propagated to the original step(s) as well, as expected. Examples: - map_action('I open door', 'I send event open_door') - map_action('Event {name} has to be sent', 'I send event {name}') - map_action('I do two things', ['First thing to do', 'Second thing to do']) :param step_text: Text of the new step, without the "given" or "when" keyword. :param existing_step_or_steps: existing step, without the "given" or "when" keyword. Could be a list of steps. """ if not isinstance(existing_step_or_steps, str): existing_step_or_steps = '\nand '.join(existing_step_or_steps) @given(step_text) def _(context, **kwargs): context.execute_steps('Given ' + existing_step_or_steps.format(**kwargs)) @when(step_text) def _(context, **kwargs): context.execute_steps('When ' + existing_step_or_steps.format(**kwargs))
Example #5
Source File: debug.py From pylink with Apache License 2.0 | 5 votes |
def step_should_hit_watchpoint(context, addr): """Checks that the watchpoint is hit at the given address. Args: context (Context): the ``Context`` instance addr (str): the address the watchpoint is expected to trigger on Returns: ``None`` Raises: TypeError: if the given address cannot be converted to an int. """ jlink = context.jlink while not jlink.halted(): time.sleep(1) cpu_halt_reasons = jlink.cpu_halt_reasons() assert len(cpu_halt_reasons) == 1 halt_reason = cpu_halt_reasons[0] assert halt_reason.data_breakpoint() index = halt_reason.Index wp = jlink.watchpoint_info(index=index) addr = int(addr, 0) assert addr == wp.Addr
Example #6
Source File: general.py From SimQLe with MIT License | 5 votes |
def load_test_connection_file_with_2_defaults(context): """Set up the context manager for a given connection_type.""" try: context.manager = ConnectionManager( file_name=CONNECTIONS_FILE_WITH_DEFAULTS) context.exc = None except Exception as e: context.exc = e
Example #7
Source File: general.py From SimQLe with MIT License | 5 votes |
def load_default_connection_file(context): """Set up the context manager for a given connection_type.""" try: context.manager = ConnectionManager(TEST_DICT) context.exc = None except Exception as e: context.exc = e
Example #8
Source File: general.py From SimQLe with MIT License | 5 votes |
def load_default_connection_file(context): """Set up the context manager for a given connection_type.""" try: context.manager = ConnectionManager() context.exc = None except Exception as e: context.exc = e
Example #9
Source File: general.py From SimQLe with MIT License | 5 votes |
def load_test_connection_file_with_default(context): """Set up the context manager for a given connection_type.""" try: context.manager = ConnectionManager( file_name=CONNECTIONS_FILE_WITH_DEFAULT) context.exc = None except Exception as e: context.exc = e
Example #10
Source File: general.py From SimQLe with MIT License | 5 votes |
def load_test_connection_file(context): """Set up the context manager for a given connection_type.""" try: context.manager = ConnectionManager(file_name=CONNECTIONS_FILE) context.exc = None except Exception as e: context.exc = e
Example #11
Source File: common.py From connect with BSD 3-Clause "New" or "Revised" License | 5 votes |
def impl(context): context.execute_steps(''' given I am logged in as that standard user ''')
Example #12
Source File: common.py From connect with BSD 3-Clause "New" or "Revised" License | 5 votes |
def impl(context): context.execute_steps(''' given there is a standard user in the database ''') context.standard_user2 = UserFactory(full_name='Another User', email='standard.user2@test.test')
Example #13
Source File: callbacks.py From pgmigrate with PostgreSQL License | 5 votes |
def step_impl(context, args): cbs = ','.join(context.callbacks) context.execute_steps('given successful pgmigrate run with ' + '"%s"' % ('-a ' + cbs + ' ' + args, ))
Example #14
Source File: debug.py From pylink with Apache License 2.0 | 5 votes |
def step_num_watchpoints(context, num): """Asserts that there are the specified number of watchpoints. Args: context (Context): the ``Context`` instance num (str): number of watchpoints that should exist Returns: ``None`` Raises: TypeError: if the given number cannot be converted to an int. """ assert int(num) == context.jlink.num_active_watchpoints()
Example #15
Source File: debug.py From pylink with Apache License 2.0 | 5 votes |
def step_num_breakpoints(context, num): """Asserts that there are the specified number of breakpoints. Args: context (Context): the ``Context`` instance num (str): number of breakpoints that should exist Returns: ``None`` Raises: TypeError: if the given number cannot be converted to an int. """ assert int(num) == context.jlink.num_active_breakpoints()
Example #16
Source File: common.py From pylink with Apache License 2.0 | 5 votes |
def step_flash_firmware_retries(context, firmware, retries): """Tries to flash the firmware with the given number of retries. Args: context (Context): the ``Context`` instance firmware (str): the name of the firmware to flash retries (int): the number of retries to do Returns: ``None`` """ jlink = context.jlink retries = int(retries) firmware = utility.firmware_path(str(firmware)) assert firmware is not None while True: try: res = utility.flash_k21(jlink, firmware) if res >= 0: break else: retries = retries - 1 except pylink.JLinkException as e: sys.stderr.write('%s%s' % (str(e), os.linesep)) retries = retries - 1 if retries < 0: break assert retries >= 0
Example #17
Source File: licenses.py From pylink with Apache License 2.0 | 5 votes |
def step_has_license(context): """Asserts the J-Link has the given licenese. Args: context (Context): the ``Context`` instance Returns: ``None`` """ jlink = context.jlink expected = context.text.strip() actual = jlink.custom_licenses.strip() assert actual.startswith(expected) assert jlink.erase_licenses()