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

Python 3.8 failures #139

Closed
hroncok opened this issue Mar 29, 2019 · 1 comment
Closed

Python 3.8 failures #139

hroncok opened this issue Mar 29, 2019 · 1 comment

Comments

@hroncok
Copy link
Member

hroncok commented Mar 29, 2019

6 tests fail on Python 3.8.0a3:

$ tox -e py38
GLOB sdist-make: .../pytest-mock/setup.py
py38 inst-nodeps: .../pytest-mock/.tox/dist/pytest-mock-1.10.3.dev1+g540c17b.zip
py38 installed: atomicwrites==1.3.0,attrs==19.1.0,coverage==4.5.3,more-itertools==7.0.0,pluggy==0.9.0,py==1.8.0,pytest==4.3.1,pytest-mock==1.10.3.dev1+g540c17b,six==1.12.0
py38 run-test-pre: PYTHONHASHSEED='858292126'
py38 runtests: commands[0] | coverage run --append --source=pytest_mock.py -m pytest test_pytest_mock.py
============================= test session starts ==============================
platform linux -- Python 3.8.0a3, pytest-4.3.1, py-1.8.0, pluggy-0.9.0
cachedir: .tox/py38/.pytest_cache
rootdir: .../pytest-mock, inifile: tox.ini
plugins: mock-1.10.3.dev1+g540c17b
collected 49 items

test_pytest_mock.py ...................FFFFF......................F..    [100%]

=================================== FAILURES ===================================
_______________ TestMockerStub.test_failure_message_with_no_name _______________

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f14e20>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f14100>

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

test_pytest_mock.py:204: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f14e20>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f14100>, kwargs = {}
expected_name = 'mock', expected_message = 'Expected call: mock()\nNot called'
stub = <MagicMock spec='function' id='140597129200016'>
exc_info = <ExceptionInfo AssertionError tblen=3>
@py_assert2 = AssertionError('expected call not found.\nExpected: mock()\nActual: not called.')
@py_assert4 = 'expected call not found.\nExpected: mock()\nActual: not called.'
@py_assert6 = False

    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 str(exc_info.value) == expected_message
E       AssertionError: assert 'expected cal...: not called.' == 'Expected call...)\nNot called'
E         - expected call not found.
E         - Expected: mock()
E         + Expected call: mock()
E         ?         +++++
E         - Actual: not called.
E         + Not called

test_pytest_mock.py:201: AssertionError
_____________ TestMockerStub.test_failure_message_with_name[None] ______________

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f101f0>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f100d0>, name = None

    @pytest.mark.parametrize("name", (None, "", "f", "The Castle of aaarrrrggh"))
    def test_failure_message_with_name(self, mocker, name):
>       self.__test_failure_message(mocker, name=name)

test_pytest_mock.py:208: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f101f0>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f100d0>
kwargs = {'name': None}, expected_name = 'mock'
expected_message = 'Expected call: mock()\nNot called'
stub = <MagicMock spec='function' id='140597129184016'>
exc_info = <ExceptionInfo AssertionError tblen=3>
@py_assert2 = AssertionError('expected call not found.\nExpected: mock()\nActual: not called.')
@py_assert4 = 'expected call not found.\nExpected: mock()\nActual: not called.'
@py_assert6 = False

    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 str(exc_info.value) == expected_message
E       AssertionError: assert 'expected cal...: not called.' == 'Expected call...)\nNot called'
E         - expected call not found.
E         - Expected: mock()
E         + Expected call: mock()
E         ?         +++++
E         - Actual: not called.
E         + Not called

test_pytest_mock.py:201: AssertionError
_______________ TestMockerStub.test_failure_message_with_name[] ________________

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f6aa60>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f6adf0>, name = ''

    @pytest.mark.parametrize("name", (None, "", "f", "The Castle of aaarrrrggh"))
    def test_failure_message_with_name(self, mocker, name):
>       self.__test_failure_message(mocker, name=name)

test_pytest_mock.py:208: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f6aa60>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f6adf0>
kwargs = {'name': ''}, expected_name = 'mock'
expected_message = 'Expected call: mock()\nNot called'
stub = <MagicMock spec='function' id='140597129555248'>
exc_info = <ExceptionInfo AssertionError tblen=3>
@py_assert2 = AssertionError('expected call not found.\nExpected: mock()\nActual: not called.')
@py_assert4 = 'expected call not found.\nExpected: mock()\nActual: not called.'
@py_assert6 = False

    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 str(exc_info.value) == expected_message
E       AssertionError: assert 'expected cal...: not called.' == 'Expected call...)\nNot called'
E         - expected call not found.
E         - Expected: mock()
E         + Expected call: mock()
E         ?         +++++
E         - Actual: not called.
E         + Not called

test_pytest_mock.py:201: AssertionError
_______________ TestMockerStub.test_failure_message_with_name[f] _______________

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f05ee0>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f05130>, name = 'f'

    @pytest.mark.parametrize("name", (None, "", "f", "The Castle of aaarrrrggh"))
    def test_failure_message_with_name(self, mocker, name):
>       self.__test_failure_message(mocker, name=name)

test_pytest_mock.py:208: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f05ee0>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f05130>
kwargs = {'name': 'f'}, expected_name = 'f'
expected_message = 'Expected call: f()\nNot called'
stub = <MagicMock name='f' spec='function' id='140597129141408'>
exc_info = <ExceptionInfo AssertionError tblen=3>
@py_assert2 = AssertionError('expected call not found.\nExpected: f()\nActual: not called.')
@py_assert4 = 'expected call not found.\nExpected: f()\nActual: not called.'
@py_assert6 = False

    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 str(exc_info.value) == expected_message
E       AssertionError: assert 'expected cal...: not called.' == 'Expected call...)\nNot called'
E         - expected call not found.
E         - Expected: f()
E         + Expected call: f()
E         ?         +++++
E         - Actual: not called.
E         + Not called

test_pytest_mock.py:201: AssertionError
___ TestMockerStub.test_failure_message_with_name[The Castle of aaarrrrggh] ____

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f73fa0>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f73b20>
name = 'The Castle of aaarrrrggh'

    @pytest.mark.parametrize("name", (None, "", "f", "The Castle of aaarrrrggh"))
    def test_failure_message_with_name(self, mocker, name):
>       self.__test_failure_message(mocker, name=name)

test_pytest_mock.py:208: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <test_pytest_mock.TestMockerStub object at 0x7fdf51f73fa0>
mocker = <pytest_mock.MockFixture object at 0x7fdf51f73b20>
kwargs = {'name': 'The Castle of aaarrrrggh'}
expected_name = 'The Castle of aaarrrrggh'
expected_message = 'Expected call: The Castle of aaarrrrggh()\nNot called'
stub = <MagicMock name='The Castle of aaarrrrggh' spec='function' id='140597129591536'>
exc_info = <ExceptionInfo AssertionError tblen=3>
@py_assert2 = AssertionError('expected call not found.\nExpected: The Castle of aaarrrrggh()\nActual: not called.')
@py_assert4 = 'expected call not found.\nExpected: The Castle of aaarrrrggh()\nActual: not called.'
@py_assert6 = False

    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 str(exc_info.value) == expected_message
E       AssertionError: assert 'expected cal...: not called.' == 'Expected call...)\nNot called'
E         - expected call not found.
E         - Expected: The Castle of aaarrrrggh()
E         + Expected call: The Castle of aaarrrrggh()
E         ?         +++++
E         - Actual: not called.
E         + Not called

test_pytest_mock.py:201: AssertionError
_________________________ test_detailed_introspection __________________________

testdir = <Testdir local('/tmp/pytest-of-churchyard/pytest-2/test_detailed_introspection0')>

    @pytest.mark.usefixtures("needs_assert_rewrite")
    def test_detailed_introspection(testdir):
        """Check that the "mock_use_standalone" is being used.
        """
        testdir.makepyfile(
            """
            def test(mocker):
                m = mocker.Mock()
                m('fo')
                m.assert_called_once_with('', bar=4)
        """
        )
        result = testdir.runpytest("-s")
>       result.stdout.fnmatch_lines(
            [
                "*AssertionError: Expected call: mock('', bar=4)*",
                "*Actual call: mock('fo')*",
                "*pytest introspection follows:*",
                "*Args:",
                "*assert ('fo',) == ('',)",
                "*At index 0 diff: 'fo' != ''*",
                "*Use -v to get the full diff*",
                "*Kwargs:*",
                "*assert {} == {'bar': 4}*",
                "*Right contains more items:*",
                "*{'bar': 4}*",
                "*Use -v to get the full diff*",
            ]
        )
E       Failed: nomatch: "*AssertionError: Expected call: mock('', bar=4)*"
E           and: '============================= test session starts =============================='
E           and: 'platform linux -- Python 3.8.0a3, pytest-4.3.1, py-1.8.0, pluggy-0.9.0'
E           and: 'rootdir: /tmp/pytest-of-churchyard/pytest-2/test_detailed_introspection0, inifile:'
E           and: 'plugins: mock-1.10.3.dev1+g540c17b'
E           and: 'collected 1 item'
E           and: ''
E           and: 'test_detailed_introspection.py F'
E           and: ''
E           and: '=================================== FAILURES ==================================='
E           and: '_____________________________________ test _____________________________________'
E           and: ''
E           and: 'mocker = <pytest_mock.MockFixture object at 0x7fdf51e08160>'
E           and: ''
E           and: '    def test(mocker):'
E           and: '        m = mocker.Mock()'
E           and: "        m('fo')"
E           and: ">       m.assert_called_once_with('', bar=4)"
E           and: 'E       AssertionError: expected call not found.'
E           and: "E       Expected: mock('', bar=4)"
E           and: "E       Actual: mock('fo')"
E           and: 'E       '
E           and: 'E       pytest introspection follows:'
E           and: 'E       '
E           and: 'E       Args:'
E           and: "E       assert ('fo',) == ('',)"
E           and: "E         At index 0 diff: 'fo' != ''"
E           and: 'E         Use -v to get the full diff'
E           and: 'E       Kwargs:'
E           and: "E       assert {} == {'bar': 4}"
E           and: 'E         Right contains more items:'
E           and: "E         {'bar': 4}"
E           and: 'E         Use -v to get the full diff'
E           and: ''
E           and: 'test_detailed_introspection.py:4: AssertionError'
E           and: '=========================== 1 failed in 0.01 seconds ==========================='
E           and: ''
E       remains unmatched: "*AssertionError: Expected call: mock('', bar=4)*"

.../pytest-mock/test_pytest_mock.py:588: Failed
----------------------------- Captured stdout call -----------------------------
============================= test session starts ==============================
platform linux -- Python 3.8.0a3, pytest-4.3.1, py-1.8.0, pluggy-0.9.0
rootdir: /tmp/pytest-of-churchyard/pytest-2/test_detailed_introspection0, inifile:
plugins: mock-1.10.3.dev1+g540c17b
collected 1 item

test_detailed_introspection.py F

=================================== FAILURES ===================================
_____________________________________ test _____________________________________

mocker = <pytest_mock.MockFixture object at 0x7fdf51e08160>

    def test(mocker):
        m = mocker.Mock()
        m('fo')
>       m.assert_called_once_with('', bar=4)
E       AssertionError: expected call not found.
E       Expected: mock('', bar=4)
E       Actual: mock('fo')
E       
E       pytest introspection follows:
E       
E       Args:
E       assert ('fo',) == ('',)
E         At index 0 diff: 'fo' != ''
E         Use -v to get the full diff
E       Kwargs:
E       assert {} == {'bar': 4}
E         Right contains more items:
E         {'bar': 4}
E         Use -v to get the full diff

test_detailed_introspection.py:4: AssertionError
=========================== 1 failed in 0.01 seconds ===========================
=============================== warnings summary ===============================
test_pytest_mock.py::test_deprecated_mock
  .../pytest-mock/pytest_mock.py:179: DeprecationWarning: "mock" fixture has been deprecated, use "mocker" instead
    warnings.warn(

-- Docs: https://docs.pytest.org/en/latest/warnings.html
=========================== short test summary info ============================
FAILED test_pytest_mock.py::TestMockerStub::test_failure_message_with_no_name
FAILED test_pytest_mock.py::TestMockerStub::test_failure_message_with_name[None]
FAILED test_pytest_mock.py::TestMockerStub::test_failure_message_with_name[]
FAILED test_pytest_mock.py::TestMockerStub::test_failure_message_with_name[f]
FAILED test_pytest_mock.py::TestMockerStub::test_failure_message_with_name[The Castle of aaarrrrggh]
FAILED test_pytest_mock.py::test_detailed_introspection
=============== 6 failed, 43 passed, 1 warnings in 1.41 seconds ================
Coverage.py warning: Module pytest_mock.py was never imported. (module-not-imported)
Coverage.py warning: No data was collected. (no-data-collected)
ERROR: InvocationError for command '.../pytest-mock/.tox/py38/bin/coverage run --append --source=pytest_mock.py -m pytest test_pytest_mock.py' (exited with code 1)
___________________________________ summary ____________________________________
ERROR:   py38: commands failed
blueyed added a commit to nicoddemus/pytest-mock that referenced this issue Mar 30, 2019
@nicoddemus
Copy link
Member

1.10.3 released with this fix. 👍

Thanks again @hroncok.

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

No branches or pull requests

2 participants