__wrapped_mock_method__ = <function NonCallableMock.assert_called_with at 0x7f7d1bc49048>
args = (<MagicMock id='140175241859144'>, 'directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
kwargs = {}, __tracebackhide__ = True
msg = "Expected call: mock('directory', b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\...bj_type': 'directory',\n 'objstorage': None,...\n \n ...Full output truncated (13 lines hidden), use '-vv' to show"
__mock_self = <MagicMock id='140175241859144'>, actual_args = ()
actual_kwargs = {'backend': <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, 'graph': None, 'obj_id': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'obj_type': 'directory', ...}
introspection = "\nArgs:\nassert () == ('directory',...7e3a80>, None)\n Right contains 5 more items, first extra item: 'directory'\n ...bj_type': 'directory',\n 'objstorage': None,...\n \n ...Full output truncated (13 lines hidden), use '-vv' to show"
@py_assert2 = ('directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
@py_assert1 = False
@py_format4 = "() == ('directory',...7e3a80>, None)\n~Right contains 5 more items, first extra item: 'directory'\n~Full diff:\n~ (\...x00\\x00\\x00\\x00'\n~- b'\\x00\\x00\\x00\\x00',...\n~\n~...Full output truncated (5 lines hidden), use '-vv' to show"
def assert_wrapper(
__wrapped_mock_method__: Callable[..., Any], *args: Any, **kwargs: Any
) -> None:
__tracebackhide__ = True
try:
> __wrapped_mock_method__(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/pytest_mock/plugin.py:414:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_mock_self = <MagicMock id='140175241859144'>
args = ('directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
kwargs = {}
expected = (('directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None), {})
_error_message = <function NonCallableMock.assert_called_with.<locals>._error_message at 0x7f7d17815378>
actual = call(backend=<MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, graph=None, obj_id=b'\x00\x00\x00\x00\x00\x...x00\x00\x00\x00\x00\x00\x00\x00\x00', obj_type='directory', objstorage=None, storage=<object object at 0x7f7d197e3a80>)
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: mock('directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
E Actual call: mock(backend=<MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, graph=None, obj_id=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', obj_type='directory', objstorage=None, storage=<object object at 0x7f7d197e3a80>)
/usr/lib/python3.7/unittest/mock.py:829: AssertionError
During handling of the above exception, another exception occurred:
__wrapped_mock_method__ = <function NonCallableMock.assert_called_once_with at 0x7f7d1bc490d0>
args = (<MagicMock id='140175241859144'>, 'directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
kwargs = {}, __tracebackhide__ = True
msg = "Expected call: mock('directory', b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\...bj_type': 'directory',\n 'objstorage': None,...\n \n ...Full output truncated (13 lines hidden), use '-vv' to show"
def assert_wrapper(
__wrapped_mock_method__: Callable[..., Any], *args: Any, **kwargs: Any
) -> None:
__tracebackhide__ = True
try:
> __wrapped_mock_method__(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/pytest_mock/plugin.py:414:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_mock_self = <MagicMock id='140175241859144'>
args = ('directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
kwargs = {}, self = <MagicMock id='140175241859144'>
def assert_called_once_with(_mock_self, *args, **kwargs):
"""assert that the mock was called exactly once and that that call was
with the specified arguments."""
self = _mock_self
if not self.call_count == 1:
msg = ("Expected '%s' to be called once. Called %s times." %
(self._mock_name or 'mock', self.call_count))
raise AssertionError(msg)
> return self.assert_called_with(*args, **kwargs)
/usr/lib/python3.7/unittest/mock.py:840:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<MagicMock id='140175241859144'>, 'directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
kwargs = {}, __tracebackhide__ = True
def wrap_assert_called_with(*args: Any, **kwargs: Any) -> None:
__tracebackhide__ = True
> assert_wrapper(_mock_module_originals["assert_called_with"], *args, **kwargs)
.tox/py3/lib/python3.7/site-packages/pytest_mock/plugin.py:447:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
__wrapped_mock_method__ = <function NonCallableMock.assert_called_with at 0x7f7d1bc49048>
args = (<MagicMock id='140175241859144'>, 'directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
kwargs = {}, __tracebackhide__ = True
msg = "Expected call: mock('directory', b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\...bj_type': 'directory',\n 'objstorage': None,...\n \n ...Full output truncated (13 lines hidden), use '-vv' to show"
__mock_self = <MagicMock id='140175241859144'>, actual_args = ()
actual_kwargs = {'backend': <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, 'graph': None, 'obj_id': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'obj_type': 'directory', ...}
introspection = "\nArgs:\nassert () == ('directory',...7e3a80>, None)\n Right contains 5 more items, first extra item: 'directory'\n ...bj_type': 'directory',\n 'objstorage': None,...\n \n ...Full output truncated (13 lines hidden), use '-vv' to show"
@py_assert2 = ('directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
@py_assert1 = False
@py_format4 = "() == ('directory',...7e3a80>, None)\n~Right contains 5 more items, first extra item: 'directory'\n~Full diff:\n~ (\...x00\\x00\\x00\\x00'\n~- b'\\x00\\x00\\x00\\x00',...\n~\n~...Full output truncated (5 lines hidden), use '-vv' to show"
def assert_wrapper(
__wrapped_mock_method__: Callable[..., Any], *args: Any, **kwargs: Any
) -> None:
__tracebackhide__ = True
try:
__wrapped_mock_method__(*args, **kwargs)
return
except AssertionError as e:
if getattr(e, "_mock_introspection_applied", 0):
msg = str(e)
else:
__mock_self = args[0]
msg = str(e)
if __mock_self.call_args is not None:
actual_args, actual_kwargs = __mock_self.call_args
introspection = ""
try:
assert actual_args == args[1:]
except AssertionError as e_args:
introspection += "\nArgs:\n" + str(e_args)
try:
assert actual_kwargs == kwargs
except AssertionError as e_kwargs:
introspection += "\nKwargs:\n" + str(e_kwargs)
if introspection:
msg += "\n\npytest introspection follows:\n" + introspection
e = AssertionError(msg)
e._mock_introspection_applied = True # type:ignore[attr-defined]
> raise e
E AssertionError: Expected call: mock('directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
E Actual call: mock(backend=<MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, graph=None, obj_id=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', obj_type='directory', objstorage=None, storage=<object object at 0x7f7d197e3a80>)
E
E pytest introspection follows:
E
E Args:
E assert () == ('directory',...7e3a80>, None)
E Right contains 5 more items, first extra item: 'directory'
E Full diff:
E (
E + ,
E - 'directory',
E - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
E - b'\x00\x00\x00\x00',...
E
E ...Full output truncated (5 lines hidden), use '-vv' to show
E Kwargs:
E assert {'backend': <...rectory', ...} == {}
E Left contains 6 more items:
E {'backend': <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>,
E 'graph': None,
E 'obj_id': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
E b'\x00\x00\x00\x00',
E 'obj_type': 'directory',
E 'objstorage': None,...
E
E ...Full output truncated (13 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/pytest_mock/plugin.py:437: AssertionError
During handling of the above exception, another exception occurred:
obj_type = 'directory', cooker_name_suffix = '', swhid_type = 'dir'
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f7d177cdac8>
@pytest.mark.parametrize(
"obj_type,cooker_name_suffix,swhid_type",
[("directory", "", "dir"), ("revision", "gitfast", "rev"),],
)
def test_cook_directory(obj_type, cooker_name_suffix, swhid_type, mocker):
storage = object()
mocker.patch("swh.storage.get_storage", return_value=storage)
backend = MagicMock(spec=InMemoryVaultBackend)
backend.fetch.return_value = b"bundle content"
mocker.patch(
"swh.vault.in_memory_backend.InMemoryVaultBackend", return_value=backend
)
cooker = MagicMock(spec=BaseVaultCooker)
cooker_cls = MagicMock(return_value=cooker)
mocker.patch("swh.vault.cookers.get_cooker_cls", return_value=cooker_cls)
runner = click.testing.CliRunner()
with tempfile.NamedTemporaryFile("a", suffix=".yml") as config_fd:
config_fd.write('{"storage": {}}')
config_fd.seek(0)
if cooker_name_suffix:
result = runner.invoke(
vault_cli_group,
[
"cook",
f"swh:1:{swhid_type}:{'0'*40}",
"-",
"-C",
config_fd.name,
"--cooker-type",
cooker_name_suffix,
],
)
else:
result = runner.invoke(
vault_cli_group,
["cook", f"swh:1:{swhid_type}:{'0'*40}", "-", "-C", config_fd.name],
)
if result.exception is not None:
raise result.exception
cooker_cls.assert_called_once_with(
f"{obj_type}_{cooker_name_suffix}" if cooker_name_suffix else obj_type,
b"\x00" * 20,
backend,
storage,
> None,
)
E AssertionError: Expected call: mock('directory', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, <object object at 0x7f7d197e3a80>, None)
E Actual call: mock(backend=<MagicMock spec='InMemoryVaultBackend' id='140175241697208'>, graph=None, obj_id=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', obj_type='directory', objstorage=None, storage=<object object at 0x7f7d197e3a80>)
E
E pytest introspection follows:
E
E Args:
E assert () == ('directory',...7e3a80>, None)
E Right contains 5 more items, first extra item: 'directory'
E Full diff:
E (
E + ,
E - 'directory',
E - b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
E - b'\x00\x00\x00\x00',...
E
E ...Full output truncated (5 lines hidden), use '-vv' to show
E Kwargs:
E assert {'backend': <...rectory', ...} == {}
E Left contains 6 more items:
E {'backend': <MagicMock spec='InMemoryVaultBackend' id='140175241697208'>,
E 'graph': None,
E 'obj_id': b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
E b'\x00\x00\x00\x00',
E 'obj_type': 'directory',
E 'objstorage': None,...
E
E ...Full output truncated (13 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/vault/tests/test_cli.py:99: AssertionError
TEST RESULT
TEST RESULT
- Run At
- May 11 2021, 4:02 PM