Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse unitest.mock assertions as diffs #256

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ikonst
Copy link
Contributor

@ikonst ikonst commented Aug 19, 2021

Currently unitest.mock failed assertions are not recognized as "diffs" in PyCharm. This teaches the plugin to recognize those assertions and emit the EqualsAssertionError with the actual/expected.

Additionally:
pytest-mock (a popular pytest plugin providing the mocker fixture) has an improved reporting feature which patches unittest.mock and changes the format of the reports.

To work well out of the box, we handle both the stock and "patched" outputs.

For example, this test

def test_foo():
    m = Mock()
    m.foo(41)
    m.foo.assert_called_once_with(42)

would result in this output:
image
and diff viewer:
image

@ikonst ikonst changed the title fix mock assert diffs [wip] fix mock assert diffs Aug 19, 2021
@ikonst ikonst force-pushed the fix-mock-assert-diffs branch from fbb41ac to 414d70a Compare August 19, 2021 13:34
teamcity/pytest_plugin.py Outdated Show resolved Hide resolved
@ikonst ikonst changed the title [wip] fix mock assert diffs [wip] Handle unitest.mock assertions as diffs Sep 10, 2021
@ikonst ikonst force-pushed the fix-mock-assert-diffs branch from 74c3704 to 7b34e96 Compare September 11, 2021 02:43
@ikonst ikonst changed the title [wip] Handle unitest.mock assertions as diffs Parse unitest.mock assertions as diffs Sep 11, 2021
@ikonst ikonst force-pushed the fix-mock-assert-diffs branch from 7b34e96 to efb4499 Compare September 11, 2021 02:46
@ikonst
Copy link
Contributor Author

ikonst commented Sep 11, 2021

@throwable-one can take a look?

@ikonst ikonst force-pushed the fix-mock-assert-diffs branch from efb4499 to 4158116 Compare September 11, 2021 02:47
@ikonst ikonst force-pushed the fix-mock-assert-diffs branch from 4158116 to 6fe7d6b Compare September 11, 2021 02:48
@ikonst
Copy link
Contributor Author

ikonst commented Oct 4, 2022

@mikekidya can review?

@ikonst
Copy link
Contributor Author

ikonst commented Oct 18, 2022

@mikekidya ping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant