Skip to content

Two tracebacks with assert_wrapper / wrap_assert_has_calls #44

Closed
@blueyed

Description

@blueyed

When using assert_has_calls I am seeing two tracebacks, but the first one should not be there?!

Traceback (most recent call last):
  File "…/pytest-mock/pytest_mock.py", line 155, in assert_wrapper
    __wrapped_mock_method__(*args, **kwargs)
  File "/usr/lib64/python3.5/unittest/mock.py", line 824, in assert_has_calls
    ) from cause
AssertionError: Calls not found.
Expected: […]
Actual: […]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "…/app/tests/test_metrics.py", line 495, in test_handle_missing_values
    expected_call(end, 2, None),
  File "…/pytest-mock/pytest_mock.py", line 181, in wrap_assert_has_calls
    *args, **kwargs)
  File "…/pytest-mock/pytest_mock.py", line 157, in assert_wrapper
    raise AssertionError(*e.args)
AssertionError: Calls not found.
Expected: […]
Actual: […]

This is with pytest-2.9.2.dev1 and Python 3.5.1.

It looks like the __tracebackhide__ = True trick is not working?!

With mock_traceback_monkeypatch=false I only get the original traceback as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions