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

Fix tests for pytest 3 #61

Closed
vincentbernat opened this issue Sep 3, 2016 · 3 comments
Closed

Fix tests for pytest 3 #61

vincentbernat opened this issue Sep 3, 2016 · 3 comments
Labels

Comments

@vincentbernat
Copy link
Contributor

Hey!

Many tests are failing when running with pytest 3.0.1:

_____________________________ TestMockerStub.test_failure_message_with_no_name _____________________________

self = <test_pytest_mock.TestMockerStub instance at 0x7f0b7f55c758>
mocker = <pytest_mock.MockFixture object at 0x7f0b7f51add0>

    def test_failure_message_with_no_name(self, mocker):
>       self.__test_failure_message(mocker)

test_pytest_mock.py:182:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <test_pytest_mock.TestMockerStub instance at 0x7f0b7f55c758>
mocker = <pytest_mock.MockFixture object at 0x7f0b7f51add0>, kwargs = {}, expected_name = 'mock'
expected_message = 'Expected call: mock()\nNot called'
stub = <MagicMock spec='function' id='139687357426384'>, exc_info = <ExceptionInfo AssertionError tblen=3>
@py_assert1 = AssertionError('Expected call: mock()\nNot called',)

    def __test_failure_message(self, mocker, **kwargs):
        expected_name = kwargs.get('name') or 'mock'
        expected_message = 'Expected call: {0}()\nNot called'.format(expected_name)
        stub = mocker.stub(**kwargs)
        with pytest.raises(AssertionError) as exc_info:
            stub.assert_called_with()
>       assert exc_info.value.msg == expected_message
E       AttributeError: 'exceptions.AssertionError' object has no attribute 'msg'

test_pytest_mock.py:179: AttributeError
@blueyed blueyed added the bug label Sep 3, 2016
@blueyed blueyed changed the title pytest3 support Fix tests for pytest 3 Sep 3, 2016
@blueyed
Copy link
Contributor

blueyed commented Sep 3, 2016

Thanks for reporting.
I've rephrased the issue: it works with pytest 3 in general.
A PR would be welcome, of course.

@vincentbernat
Copy link
Contributor Author

I'll do a PR shortly.

@nicoddemus
Copy link
Member

Fixed in #63

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

No branches or pull requests

3 participants