Created
January 30, 2019 16:17
-
-
Save mbolivar/654208a6535999c7748ed9bc26eaf3a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(west) plop: ~/src/zephyr/zephyr/scripts/west_commands (pr12879) mbolivar | |
$ PYTHONPATH=$(west list --format="{abspath}" west)/src:$PWD py.test | |
==================================================================== test session starts ===================================================================== | |
platform linux -- Python 3.6.7, pytest-4.1.1, py-1.7.0, pluggy-0.8.1 | |
rootdir: /home/mbolivar/src/zephyr/zephyr/scripts/west_commands, inifile: | |
collected 45 items | |
tests/test_imports.py . [ 2%] | |
tests/test_nrfjprog.py ................................ [ 73%] | |
tests/test_pyocd.py FFFFFFFFFFFF [100%] | |
========================================================================== FAILURES ========================================================================== | |
_____________________________________________________________ test_flash[pyocd_args0-expected0] ______________________________________________________________ | |
cc = <MagicMock name='check_call' id='140005014758568'> | |
pyocd_args = {'board_id': 'test-board-id', 'daparg': 'test-daparg', 'flash': 'test-flash', 'flash_addr': 2781, ...} | |
expected = ['test-flash', '-a', '0xadd', '-da', 'test-daparg', '-t', ...], pyocd = <function pyocd.<locals>._factory at 0x7f55752fb6a8> | |
@pytest.mark.parametrize('pyocd_args,expected', [ | |
(TEST_ALL_KWARGS, FLASH_ALL_EXPECTED_CALL), | |
(TEST_DEF_KWARGS, FLASH_DEF_EXPECTED_CALL) | |
]) | |
@patch('runners.pyocd.PyOcdBinaryRunner.check_call') | |
def test_flash(cc, pyocd_args, expected, pyocd): | |
> pyocd(pyocd_args).run('flash') | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:145: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = {'board_id': 'test-board-id', 'daparg': 'test-daparg', 'flash': 'test-flash', 'flash_addr': 2781, ...} | |
def _factory(args): | |
# Ensure kernel binaries exist (as empty files, so commands | |
# which use them must be patched out). | |
tmpdir.ensure(RC_KERNEL_HEX) | |
tmpdir.ensure(RC_KERNEL_ELF) | |
tmpdir.chdir() | |
if isinstance(args, dict): | |
> return PyOcdBinaryRunner(runner_config, TEST_TARGET, **args) | |
E TypeError: __init__() got an unexpected keyword argument 'flash' | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:126: TypeError | |
_____________________________________________________________ test_flash[pyocd_args1-expected1] ______________________________________________________________ | |
cc = <MagicMock name='check_call' id='140005015521376'>, pyocd_args = {}, expected = ['pyocd flash', '-t', 'test-target', 'test-zephyr.hex'] | |
pyocd = <function pyocd.<locals>._factory at 0x7f557526a048> | |
@pytest.mark.parametrize('pyocd_args,expected', [ | |
(TEST_ALL_KWARGS, FLASH_ALL_EXPECTED_CALL), | |
(TEST_DEF_KWARGS, FLASH_DEF_EXPECTED_CALL) | |
]) | |
@patch('runners.pyocd.PyOcdBinaryRunner.check_call') | |
def test_flash(cc, pyocd_args, expected, pyocd): | |
pyocd(pyocd_args).run('flash') | |
> cc.assert_called_once_with(expected) | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:146: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/lib/python3.6/unittest/mock.py:825: in assert_called_once_with | |
return self.assert_called_with(*args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
_mock_self = <MagicMock name='check_call' id='140005015521376'>, args = (['pyocd flash', '-t', 'test-target', 'test-zephyr.hex'],), kwargs = {} | |
expected = ((['pyocd flash', '-t', 'test-target', 'test-zephyr.hex'],), {}) | |
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f557526a158> | |
actual = call(['pyocd', 'flash', '-t', 'test-target', 'test-zephyr.hex']), cause = None | |
def assert_called_with(_mock_self, *args, **kwargs): | |
"""assert that the mock was called with the specified arguments. | |
Raises an AssertionError if the args and keyword args passed in are | |
different to the last call to the mock.""" | |
self = _mock_self | |
if self.call_args is None: | |
expected = self._format_mock_call_signature(args, kwargs) | |
raise AssertionError('Expected call: %s\nNot called' % (expected,)) | |
def _error_message(): | |
msg = self._format_mock_failure_message(args, kwargs) | |
return msg | |
expected = self._call_matcher((args, kwargs)) | |
actual = self._call_matcher(self.call_args) | |
if expected != actual: | |
cause = expected if isinstance(expected, Exception) else None | |
> raise AssertionError(_error_message()) from cause | |
E AssertionError: Expected call: check_call(['pyocd flash', '-t', 'test-target', 'test-zephyr.hex']) | |
E Actual call: check_call(['pyocd', 'flash', '-t', 'test-target', 'test-zephyr.hex']) | |
/usr/lib/python3.6/unittest/mock.py:814: AssertionError | |
-------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------- | |
Flashing Target Device | |
_____________________________________________________________ test_debug[pyocd_args0-expectedv0] _____________________________________________________________ | |
rsc = <MagicMock name='run_server_and_client' id='140005014623792'> | |
pyocd_args = {'board_id': 'test-board-id', 'daparg': 'test-daparg', 'flash': 'test-flash', 'flash_addr': 2781, ...} | |
expectedv = (['test-pyocd-gdbserver', '-da', 'test-daparg', '-p', '1', '-t', ...], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :1', '-ex', 'monitor halt', ...]) | |
pyocd = <function pyocd.<locals>._factory at 0x7f557526ad08> | |
@pytest.mark.parametrize('pyocd_args,expectedv', [ | |
(TEST_ALL_KWARGS, (DEBUG_ALL_EXPECTED_SERVER, DEBUG_ALL_EXPECTED_CLIENT)), | |
(TEST_DEF_KWARGS, (DEBUG_DEF_EXPECTED_SERVER, DEBUG_DEF_EXPECTED_CLIENT)) | |
]) | |
@patch('runners.pyocd.PyOcdBinaryRunner.run_server_and_client') | |
def test_debug(rsc, pyocd_args, expectedv, pyocd): | |
> pyocd(pyocd_args).run('debug') | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:155: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = {'board_id': 'test-board-id', 'daparg': 'test-daparg', 'flash': 'test-flash', 'flash_addr': 2781, ...} | |
def _factory(args): | |
# Ensure kernel binaries exist (as empty files, so commands | |
# which use them must be patched out). | |
tmpdir.ensure(RC_KERNEL_HEX) | |
tmpdir.ensure(RC_KERNEL_ELF) | |
tmpdir.chdir() | |
if isinstance(args, dict): | |
> return PyOcdBinaryRunner(runner_config, TEST_TARGET, **args) | |
E TypeError: __init__() got an unexpected keyword argument 'flash' | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:126: TypeError | |
_____________________________________________________________ test_debug[pyocd_args1-expectedv1] _____________________________________________________________ | |
rsc = <MagicMock name='run_server_and_client' id='140005014610496'>, pyocd_args = {} | |
expectedv = (['pyocd gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', ...]) | |
pyocd = <function pyocd.<locals>._factory at 0x7f557526ab70> | |
@pytest.mark.parametrize('pyocd_args,expectedv', [ | |
(TEST_ALL_KWARGS, (DEBUG_ALL_EXPECTED_SERVER, DEBUG_ALL_EXPECTED_CLIENT)), | |
(TEST_DEF_KWARGS, (DEBUG_DEF_EXPECTED_SERVER, DEBUG_DEF_EXPECTED_CLIENT)) | |
]) | |
@patch('runners.pyocd.PyOcdBinaryRunner.run_server_and_client') | |
def test_debug(rsc, pyocd_args, expectedv, pyocd): | |
pyocd(pyocd_args).run('debug') | |
> rsc.assert_called_once_with(*expectedv) | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:156: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/lib/python3.6/unittest/mock.py:825: in assert_called_once_with | |
return self.assert_called_with(*args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
_mock_self = <MagicMock name='run_server_and_client' id='140005014610496'> | |
args = (['pyocd gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', ...]) | |
kwargs = {} | |
expected = ((['pyocd gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', ...]), {}) | |
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f55754b9f28> | |
actual = call(['pyocd', 'gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', '-ex', 'monitor reset', '-ex', 'load']) | |
cause = None | |
def assert_called_with(_mock_self, *args, **kwargs): | |
"""assert that the mock was called with the specified arguments. | |
Raises an AssertionError if the args and keyword args passed in are | |
different to the last call to the mock.""" | |
self = _mock_self | |
if self.call_args is None: | |
expected = self._format_mock_call_signature(args, kwargs) | |
raise AssertionError('Expected call: %s\nNot called' % (expected,)) | |
def _error_message(): | |
msg = self._format_mock_failure_message(args, kwargs) | |
return msg | |
expected = self._call_matcher((args, kwargs)) | |
actual = self._call_matcher(self.call_args) | |
if expected != actual: | |
cause = expected if isinstance(expected, Exception) else None | |
> raise AssertionError(_error_message()) from cause | |
E AssertionError: Expected call: run_server_and_client(['pyocd gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', '-ex', 'monitor reset', '-ex', 'load']) | |
E Actual call: run_server_and_client(['pyocd', 'gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', '-ex', 'monitor reset', '-ex', 'load']) | |
/usr/lib/python3.6/unittest/mock.py:814: AssertionError | |
-------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------- | |
pyOCD GDB server running on port 3333 | |
__________________________________________________________ test_debugserver[pyocd_args0-expected0] ___________________________________________________________ | |
cc = <MagicMock name='check_call' id='140005015488048'> | |
pyocd_args = {'board_id': 'test-board-id', 'daparg': 'test-daparg', 'flash': 'test-flash', 'flash_addr': 2781, ...} | |
expected = ['test-pyocd-gdbserver', '-da', 'test-daparg', '-p', '1', '-t', ...], pyocd = <function pyocd.<locals>._factory at 0x7f557526ad08> | |
@pytest.mark.parametrize('pyocd_args,expected', [ | |
(TEST_ALL_KWARGS, DEBUGSERVER_ALL_EXPECTED_CALL), | |
(TEST_DEF_KWARGS, DEBUGSERVER_DEF_EXPECTED_CALL) | |
]) | |
@patch('runners.pyocd.PyOcdBinaryRunner.check_call') | |
def test_debugserver(cc, pyocd_args, expected, pyocd): | |
> pyocd(pyocd_args).run('debugserver') | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:165: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
args = {'board_id': 'test-board-id', 'daparg': 'test-daparg', 'flash': 'test-flash', 'flash_addr': 2781, ...} | |
def _factory(args): | |
# Ensure kernel binaries exist (as empty files, so commands | |
# which use them must be patched out). | |
tmpdir.ensure(RC_KERNEL_HEX) | |
tmpdir.ensure(RC_KERNEL_ELF) | |
tmpdir.chdir() | |
if isinstance(args, dict): | |
> return PyOcdBinaryRunner(runner_config, TEST_TARGET, **args) | |
E TypeError: __init__() got an unexpected keyword argument 'flash' | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:126: TypeError | |
__________________________________________________________ test_debugserver[pyocd_args1-expected1] ___________________________________________________________ | |
cc = <MagicMock name='check_call' id='140005015387720'>, pyocd_args = {}, expected = ['pyocd gdbserver', '-p', '3333', '-t', 'test-target'] | |
pyocd = <function pyocd.<locals>._factory at 0x7f55752fb730> | |
@pytest.mark.parametrize('pyocd_args,expected', [ | |
(TEST_ALL_KWARGS, DEBUGSERVER_ALL_EXPECTED_CALL), | |
(TEST_DEF_KWARGS, DEBUGSERVER_DEF_EXPECTED_CALL) | |
]) | |
@patch('runners.pyocd.PyOcdBinaryRunner.check_call') | |
def test_debugserver(cc, pyocd_args, expected, pyocd): | |
pyocd(pyocd_args).run('debugserver') | |
> cc.assert_called_once_with(expected) | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:166: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/lib/python3.6/unittest/mock.py:825: in assert_called_once_with | |
return self.assert_called_with(*args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
_mock_self = <MagicMock name='check_call' id='140005015387720'>, args = (['pyocd gdbserver', '-p', '3333', '-t', 'test-target'],), kwargs = {} | |
expected = ((['pyocd gdbserver', '-p', '3333', '-t', 'test-target'],), {}) | |
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f557527c0d0> | |
actual = call(['pyocd', 'gdbserver', '-p', '3333', '-t', 'test-target']), cause = None | |
def assert_called_with(_mock_self, *args, **kwargs): | |
"""assert that the mock was called with the specified arguments. | |
Raises an AssertionError if the args and keyword args passed in are | |
different to the last call to the mock.""" | |
self = _mock_self | |
if self.call_args is None: | |
expected = self._format_mock_call_signature(args, kwargs) | |
raise AssertionError('Expected call: %s\nNot called' % (expected,)) | |
def _error_message(): | |
msg = self._format_mock_failure_message(args, kwargs) | |
return msg | |
expected = self._call_matcher((args, kwargs)) | |
actual = self._call_matcher(self.call_args) | |
if expected != actual: | |
cause = expected if isinstance(expected, Exception) else None | |
> raise AssertionError(_error_message()) from cause | |
E AssertionError: Expected call: check_call(['pyocd gdbserver', '-p', '3333', '-t', 'test-target']) | |
E Actual call: check_call(['pyocd', 'gdbserver', '-p', '3333', '-t', 'test-target']) | |
/usr/lib/python3.6/unittest/mock.py:814: AssertionError | |
-------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------- | |
pyOCD GDB server running on port 3333 | |
________________________________________________________ test_flash_args[pyocd_args0-2781-expected0] _________________________________________________________ | |
cc = <MagicMock name='check_call' id='140005016909472'>, bc = <MagicMock name='BuildConfiguration' id='140005016908800'> | |
pyocd_args = ['--target', 'test-target', '--daparg', 'test-daparg', '--flash', 'test-flash', ...], flash_addr = 2781 | |
expected = ['test-flash', '-a', '0xadd', '-da', 'test-daparg', '-t', ...], pyocd = <function pyocd.<locals>._factory at 0x7f55752fb6a8> | |
@pytest.mark.parametrize('pyocd_args,flash_addr,expected', [ | |
(TEST_ALL_PARAMS, TEST_ADDR, FLASH_ALL_EXPECTED_CALL), | |
(TEST_DEF_PARAMS, 0x0, FLASH_DEF_EXPECTED_CALL) | |
]) | |
@patch('runners.pyocd.BuildConfiguration') | |
@patch('runners.pyocd.PyOcdBinaryRunner.check_call') | |
def test_flash_args(cc, bc, pyocd_args, flash_addr, expected, pyocd): | |
with patch.object(PyOcdBinaryRunner, 'get_flash_address', | |
return_value=flash_addr): | |
> pyocd(pyocd_args).run('flash') | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:185: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:130: in _factory | |
arg_namespace = parser.parse_args(args) | |
/usr/lib/python3.6/argparse.py:1746: in parse_args | |
self.error(msg % ' '.join(argv)) | |
/usr/lib/python3.6/argparse.py:2402: in error | |
self.exit(2, _('%(prog)s: error: %(message)s\n') % args) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = ArgumentParser(prog='py.test', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True) | |
status = 2, message = 'py.test: error: unrecognized arguments: --gdbserver test-pyocd-gdbserver\n' | |
def exit(self, status=0, message=None): | |
if message: | |
self._print_message(message, _sys.stderr) | |
> _sys.exit(status) | |
E SystemExit: 2 | |
/usr/lib/python3.6/argparse.py:2389: SystemExit | |
-------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------- | |
usage: py.test [-h] [--dt-flash {Y,y,N,n,yes,no,YES,NO}] --target TARGET | |
[--daparg DAPARG] [--flash-opt FLASH_OPT] | |
[--frequency FREQUENCY] [--gdb-port GDB_PORT] [--tui] | |
[--board-id BOARD_ID] | |
py.test: error: unrecognized arguments: --gdbserver test-pyocd-gdbserver | |
__________________________________________________________ test_flash_args[pyocd_args1-0-expected1] __________________________________________________________ | |
cc = <MagicMock name='check_call' id='140005015630960'>, bc = <MagicMock name='BuildConfiguration' id='140005015632304'> | |
pyocd_args = ['--target', 'test-target'], flash_addr = 0, expected = ['pyocd flash', '-t', 'test-target', 'test-zephyr.hex'] | |
pyocd = <function pyocd.<locals>._factory at 0x7f557527cb70> | |
@pytest.mark.parametrize('pyocd_args,flash_addr,expected', [ | |
(TEST_ALL_PARAMS, TEST_ADDR, FLASH_ALL_EXPECTED_CALL), | |
(TEST_DEF_PARAMS, 0x0, FLASH_DEF_EXPECTED_CALL) | |
]) | |
@patch('runners.pyocd.BuildConfiguration') | |
@patch('runners.pyocd.PyOcdBinaryRunner.check_call') | |
def test_flash_args(cc, bc, pyocd_args, flash_addr, expected, pyocd): | |
with patch.object(PyOcdBinaryRunner, 'get_flash_address', | |
return_value=flash_addr): | |
pyocd(pyocd_args).run('flash') | |
bc.assert_called_once_with(RC_BUILD_DIR) | |
> cc.assert_called_once_with(expected) | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:187: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/lib/python3.6/unittest/mock.py:825: in assert_called_once_with | |
return self.assert_called_with(*args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
_mock_self = <MagicMock name='check_call' id='140005015630960'>, args = (['pyocd flash', '-t', 'test-target', 'test-zephyr.hex'],), kwargs = {} | |
expected = ((['pyocd flash', '-t', 'test-target', 'test-zephyr.hex'],), {}) | |
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f557527c048> | |
actual = call(['pyocd', 'flash', '-t', 'test-target', 'test-zephyr.hex']), cause = None | |
def assert_called_with(_mock_self, *args, **kwargs): | |
"""assert that the mock was called with the specified arguments. | |
Raises an AssertionError if the args and keyword args passed in are | |
different to the last call to the mock.""" | |
self = _mock_self | |
if self.call_args is None: | |
expected = self._format_mock_call_signature(args, kwargs) | |
raise AssertionError('Expected call: %s\nNot called' % (expected,)) | |
def _error_message(): | |
msg = self._format_mock_failure_message(args, kwargs) | |
return msg | |
expected = self._call_matcher((args, kwargs)) | |
actual = self._call_matcher(self.call_args) | |
if expected != actual: | |
cause = expected if isinstance(expected, Exception) else None | |
> raise AssertionError(_error_message()) from cause | |
E AssertionError: Expected call: check_call(['pyocd flash', '-t', 'test-target', 'test-zephyr.hex']) | |
E Actual call: check_call(['pyocd', 'flash', '-t', 'test-target', 'test-zephyr.hex']) | |
/usr/lib/python3.6/unittest/mock.py:814: AssertionError | |
-------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------- | |
Flashing Target Device | |
__________________________________________________________ test_debug_args[pyocd_args0-expectedv0] ___________________________________________________________ | |
rsc = <MagicMock name='run_server_and_client' id='140005015448208'>, bc = <MagicMock name='BuildConfiguration' id='140005015448488'> | |
pyocd_args = ['--target', 'test-target', '--daparg', 'test-daparg', '--flash', 'test-flash', ...] | |
expectedv = (['test-pyocd-gdbserver', '-da', 'test-daparg', '-p', '1', '-t', ...], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :1', '-ex', 'monitor halt', ...]) | |
pyocd = <function pyocd.<locals>._factory at 0x7f557527cd90> | |
@pytest.mark.parametrize('pyocd_args, expectedv', [ | |
(TEST_ALL_PARAMS, (DEBUG_ALL_EXPECTED_SERVER, DEBUG_ALL_EXPECTED_CLIENT)), | |
(TEST_DEF_PARAMS, (DEBUG_DEF_EXPECTED_SERVER, DEBUG_DEF_EXPECTED_CLIENT)), | |
]) | |
@patch('runners.pyocd.BuildConfiguration') | |
@patch('runners.pyocd.PyOcdBinaryRunner.run_server_and_client') | |
def test_debug_args(rsc, bc, pyocd_args, expectedv, pyocd): | |
> pyocd(pyocd_args).run('debug') | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:197: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:130: in _factory | |
arg_namespace = parser.parse_args(args) | |
/usr/lib/python3.6/argparse.py:1746: in parse_args | |
self.error(msg % ' '.join(argv)) | |
/usr/lib/python3.6/argparse.py:2402: in error | |
self.exit(2, _('%(prog)s: error: %(message)s\n') % args) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = ArgumentParser(prog='py.test', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True) | |
status = 2, message = 'py.test: error: unrecognized arguments: --gdbserver test-pyocd-gdbserver\n' | |
def exit(self, status=0, message=None): | |
if message: | |
self._print_message(message, _sys.stderr) | |
> _sys.exit(status) | |
E SystemExit: 2 | |
/usr/lib/python3.6/argparse.py:2389: SystemExit | |
-------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------- | |
usage: py.test [-h] [--dt-flash {Y,y,N,n,yes,no,YES,NO}] --target TARGET | |
[--daparg DAPARG] [--flash-opt FLASH_OPT] | |
[--frequency FREQUENCY] [--gdb-port GDB_PORT] [--tui] | |
[--board-id BOARD_ID] | |
py.test: error: unrecognized arguments: --gdbserver test-pyocd-gdbserver | |
__________________________________________________________ test_debug_args[pyocd_args1-expectedv1] ___________________________________________________________ | |
rsc = <MagicMock name='run_server_and_client' id='140005015592408'>, bc = <MagicMock name='BuildConfiguration' id='140005015592912'> | |
pyocd_args = ['--target', 'test-target'] | |
expectedv = (['pyocd gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', ...]) | |
pyocd = <function pyocd.<locals>._factory at 0x7f557527cb70> | |
@pytest.mark.parametrize('pyocd_args, expectedv', [ | |
(TEST_ALL_PARAMS, (DEBUG_ALL_EXPECTED_SERVER, DEBUG_ALL_EXPECTED_CLIENT)), | |
(TEST_DEF_PARAMS, (DEBUG_DEF_EXPECTED_SERVER, DEBUG_DEF_EXPECTED_CLIENT)), | |
]) | |
@patch('runners.pyocd.BuildConfiguration') | |
@patch('runners.pyocd.PyOcdBinaryRunner.run_server_and_client') | |
def test_debug_args(rsc, bc, pyocd_args, expectedv, pyocd): | |
pyocd(pyocd_args).run('debug') | |
bc.assert_called_once_with(RC_BUILD_DIR) | |
> rsc.assert_called_once_with(*expectedv) | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:199: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/lib/python3.6/unittest/mock.py:825: in assert_called_once_with | |
return self.assert_called_with(*args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
_mock_self = <MagicMock name='run_server_and_client' id='140005015592408'> | |
args = (['pyocd gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', ...]) | |
kwargs = {} | |
expected = ((['pyocd gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', ...]), {}) | |
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f557527cae8> | |
actual = call(['pyocd', 'gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', '-ex', 'monitor reset', '-ex', 'load']) | |
cause = None | |
def assert_called_with(_mock_self, *args, **kwargs): | |
"""assert that the mock was called with the specified arguments. | |
Raises an AssertionError if the args and keyword args passed in are | |
different to the last call to the mock.""" | |
self = _mock_self | |
if self.call_args is None: | |
expected = self._format_mock_call_signature(args, kwargs) | |
raise AssertionError('Expected call: %s\nNot called' % (expected,)) | |
def _error_message(): | |
msg = self._format_mock_failure_message(args, kwargs) | |
return msg | |
expected = self._call_matcher((args, kwargs)) | |
actual = self._call_matcher(self.call_args) | |
if expected != actual: | |
cause = expected if isinstance(expected, Exception) else None | |
> raise AssertionError(_error_message()) from cause | |
E AssertionError: Expected call: run_server_and_client(['pyocd gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', '-ex', 'monitor reset', '-ex', 'load']) | |
E Actual call: run_server_and_client(['pyocd', 'gdbserver', '-p', '3333', '-t', 'test-target'], ['test-none-gdb', 'test-zephyr.elf', '-ex', 'target remote :3333', '-ex', 'monitor halt', '-ex', 'monitor reset', '-ex', 'load']) | |
/usr/lib/python3.6/unittest/mock.py:814: AssertionError | |
-------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------- | |
pyOCD GDB server running on port 3333 | |
________________________________________________________ test_debugserver_args[pyocd_args0-expected0] ________________________________________________________ | |
cc = <MagicMock name='check_call' id='140005015540344'>, bc = <MagicMock name='BuildConfiguration' id='140005015540120'> | |
pyocd_args = ['--target', 'test-target', '--daparg', 'test-daparg', '--flash', 'test-flash', ...] | |
expected = ['test-pyocd-gdbserver', '-da', 'test-daparg', '-p', '1', '-t', ...], pyocd = <function pyocd.<locals>._factory at 0x7f557526af28> | |
@pytest.mark.parametrize('pyocd_args, expected', [ | |
(TEST_ALL_PARAMS, DEBUGSERVER_ALL_EXPECTED_CALL), | |
(TEST_DEF_PARAMS, DEBUGSERVER_DEF_EXPECTED_CALL), | |
]) | |
@patch('runners.pyocd.BuildConfiguration') | |
@patch('runners.pyocd.PyOcdBinaryRunner.check_call') | |
def test_debugserver_args(cc, bc, pyocd_args, expected, pyocd): | |
> pyocd(pyocd_args).run('debugserver') | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:209: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:130: in _factory | |
arg_namespace = parser.parse_args(args) | |
/usr/lib/python3.6/argparse.py:1746: in parse_args | |
self.error(msg % ' '.join(argv)) | |
/usr/lib/python3.6/argparse.py:2402: in error | |
self.exit(2, _('%(prog)s: error: %(message)s\n') % args) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
self = ArgumentParser(prog='py.test', usage=None, description=None, formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True) | |
status = 2, message = 'py.test: error: unrecognized arguments: --gdbserver test-pyocd-gdbserver\n' | |
def exit(self, status=0, message=None): | |
if message: | |
self._print_message(message, _sys.stderr) | |
> _sys.exit(status) | |
E SystemExit: 2 | |
/usr/lib/python3.6/argparse.py:2389: SystemExit | |
-------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------- | |
usage: py.test [-h] [--dt-flash {Y,y,N,n,yes,no,YES,NO}] --target TARGET | |
[--daparg DAPARG] [--flash-opt FLASH_OPT] | |
[--frequency FREQUENCY] [--gdb-port GDB_PORT] [--tui] | |
[--board-id BOARD_ID] | |
py.test: error: unrecognized arguments: --gdbserver test-pyocd-gdbserver | |
________________________________________________________ test_debugserver_args[pyocd_args1-expected1] ________________________________________________________ | |
cc = <MagicMock name='check_call' id='140005015422064'>, bc = <MagicMock name='BuildConfiguration' id='140005015421616'> | |
pyocd_args = ['--target', 'test-target'], expected = ['pyocd gdbserver', '-p', '3333', '-t', 'test-target'] | |
pyocd = <function pyocd.<locals>._factory at 0x7f557527cd08> | |
@pytest.mark.parametrize('pyocd_args, expected', [ | |
(TEST_ALL_PARAMS, DEBUGSERVER_ALL_EXPECTED_CALL), | |
(TEST_DEF_PARAMS, DEBUGSERVER_DEF_EXPECTED_CALL), | |
]) | |
@patch('runners.pyocd.BuildConfiguration') | |
@patch('runners.pyocd.PyOcdBinaryRunner.check_call') | |
def test_debugserver_args(cc, bc, pyocd_args, expected, pyocd): | |
pyocd(pyocd_args).run('debugserver') | |
bc.assert_called_once_with(RC_BUILD_DIR) | |
> cc.assert_called_once_with(expected) | |
/home/mbolivar/src/zephyr/zephyr/scripts/west_commands/tests/test_pyocd.py:211: | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
/usr/lib/python3.6/unittest/mock.py:825: in assert_called_once_with | |
return self.assert_called_with(*args, **kwargs) | |
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ | |
_mock_self = <MagicMock name='check_call' id='140005015422064'>, args = (['pyocd gdbserver', '-p', '3333', '-t', 'test-target'],), kwargs = {} | |
expected = ((['pyocd gdbserver', '-p', '3333', '-t', 'test-target'],), {}) | |
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f557527c0d0> | |
actual = call(['pyocd', 'gdbserver', '-p', '3333', '-t', 'test-target']), cause = None | |
def assert_called_with(_mock_self, *args, **kwargs): | |
"""assert that the mock was called with the specified arguments. | |
Raises an AssertionError if the args and keyword args passed in are | |
different to the last call to the mock.""" | |
self = _mock_self | |
if self.call_args is None: | |
expected = self._format_mock_call_signature(args, kwargs) | |
raise AssertionError('Expected call: %s\nNot called' % (expected,)) | |
def _error_message(): | |
msg = self._format_mock_failure_message(args, kwargs) | |
return msg | |
expected = self._call_matcher((args, kwargs)) | |
actual = self._call_matcher(self.call_args) | |
if expected != actual: | |
cause = expected if isinstance(expected, Exception) else None | |
> raise AssertionError(_error_message()) from cause | |
E AssertionError: Expected call: check_call(['pyocd gdbserver', '-p', '3333', '-t', 'test-target']) | |
E Actual call: check_call(['pyocd', 'gdbserver', '-p', '3333', '-t', 'test-target']) | |
/usr/lib/python3.6/unittest/mock.py:814: AssertionError | |
-------------------------------------------------------------------- Captured stdout call -------------------------------------------------------------------- | |
pyOCD GDB server running on port 3333 | |
============================================================ 12 failed, 33 passed in 0.79 seconds ============================================================ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment