Bug 1694192
Summary: | python-pytest-mock test failures with Python 3.8 | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Miro Hrončok <mhroncok> |
Component: | python-pytest-mock | Assignee: | Julien Enselme <jujens> |
Status: | CLOSED DUPLICATE | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | rawhide | CC: | jujens |
Target Milestone: | --- | Keywords: | Reopened |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2019-07-28 22:32:51 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | 1692375 | ||
Bug Blocks: | 1686977 |
Description
Miro Hrončok
2019-03-29 18:14:37 UTC
Upgrading to 1.10.2 does NOT help. Fixed upstream in 1.10.3 https://github.com/pytest-dev/pytest-mock/pull/140 1.10.4 fails again: https://copr.fedorainfracloud.org/coprs/g/python/python3.8/build/971242/ Are you sure? From your link, it seems it worked. That link shows "failed". I've tried again to be sure: https://copr.fedorainfracloud.org/coprs/g/python/python3.8/build/971268/ again "failed" The failure is on Python 2 however (weird): + py.test-2.7 test_pytest_mock.py ============================= test session starts ============================== platform linux2 -- Python 2.7.16, pytest-4.4.1, py-1.8.0, pluggy-0.11.0 rootdir: /builddir/build/BUILD/pytest-mock-1.10.4, inifile: tox.ini plugins: mock-1.10.4 collected 50 items test_pytest_mock.py ...................FFFFF....x..x..............sF.. [100%] =================================== FAILURES =================================== _______________ TestMockerStub.test_failure_message_with_no_name _______________ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916d249e0> mocker = <pytest_mock.MockFixture object at 0x7f3916e9ced0> def test_failure_message_with_no_name(self, mocker): > self.__test_failure_message(mocker) test_pytest_mock.py:223: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916d249e0> mocker = <pytest_mock.MockFixture object at 0x7f3916e9ced0>, kwargs = {} expected_name = 'mock', msg = 'Expected call: {0}()\nNot called' expected_message = 'Expected call: mock()\nNot called' stub = <MagicMock spec='function' id='139883174282960'> exc_info = <ExceptionInfo AssertionError tblen=3> @py_assert2 = AssertionError(u'expected call not found.\nExpected: mock()\nActual: not called.',) @py_assert4 = 'expected call not found.\nExpected: mock()\nActual: not called.' def __test_failure_message(self, mocker, **kwargs): expected_name = kwargs.get("name") or "mock" if PY38: msg = "expected call not found.\nExpected: {0}()\nActual: not called." else: msg = "Expected call: {0}()\nNot called" expected_message = msg.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:220: AssertionError _____________ TestMockerStub.test_failure_message_with_name[None] ______________ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916eaa638> mocker = <pytest_mock.MockFixture object at 0x7f3916d17e50>, 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:227: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916eaa638> mocker = <pytest_mock.MockFixture object at 0x7f3916d17e50> kwargs = {'name': None}, expected_name = 'mock' msg = 'Expected call: {0}()\nNot called' expected_message = 'Expected call: mock()\nNot called' stub = <MagicMock spec='function' id='139883172691024'> exc_info = <ExceptionInfo AssertionError tblen=3> @py_assert2 = AssertionError(u'expected call not found.\nExpected: mock()\nActual: not called.',) @py_assert4 = 'expected call not found.\nExpected: mock()\nActual: not called.' def __test_failure_message(self, mocker, **kwargs): expected_name = kwargs.get("name") or "mock" if PY38: msg = "expected call not found.\nExpected: {0}()\nActual: not called." else: msg = "Expected call: {0}()\nNot called" expected_message = msg.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:220: AssertionError _______________ TestMockerStub.test_failure_message_with_name[] ________________ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916d8b9e0> mocker = <pytest_mock.MockFixture object at 0x7f3916d87410>, 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:227: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916d8b9e0> mocker = <pytest_mock.MockFixture object at 0x7f3916d87410> kwargs = {'name': ''}, expected_name = 'mock' msg = 'Expected call: {0}()\nNot called' expected_message = 'Expected call: mock()\nNot called' stub = <MagicMock spec='function' id='139883173148304'> exc_info = <ExceptionInfo AssertionError tblen=3> @py_assert2 = AssertionError(u'expected call not found.\nExpected: mock()\nActual: not called.',) @py_assert4 = 'expected call not found.\nExpected: mock()\nActual: not called.' def __test_failure_message(self, mocker, **kwargs): expected_name = kwargs.get("name") or "mock" if PY38: msg = "expected call not found.\nExpected: {0}()\nActual: not called." else: msg = "Expected call: {0}()\nNot called" expected_message = msg.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:220: AssertionError _______________ TestMockerStub.test_failure_message_with_name[f] _______________ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916df9488> mocker = <pytest_mock.MockFixture object at 0x7f3916d9b3d0>, 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:227: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916df9488> mocker = <pytest_mock.MockFixture object at 0x7f3916d9b3d0> kwargs = {'name': 'f'}, expected_name = 'f' msg = 'Expected call: {0}()\nNot called' expected_message = 'Expected call: f()\nNot called' stub = <MagicMock name='f' spec='function' id='139883173230992'> exc_info = <ExceptionInfo AssertionError tblen=3> @py_assert2 = AssertionError(u'expected call not found.\nExpected: f()\nActual: not called.',) @py_assert4 = 'expected call not found.\nExpected: f()\nActual: not called.' def __test_failure_message(self, mocker, **kwargs): expected_name = kwargs.get("name") or "mock" if PY38: msg = "expected call not found.\nExpected: {0}()\nActual: not called." else: msg = "Expected call: {0}()\nNot called" expected_message = msg.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:220: AssertionError ___ TestMockerStub.test_failure_message_with_name[The Castle of aaarrrrggh] ____ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916d29b48> mocker = <pytest_mock.MockFixture object at 0x7f3916efc4d0> 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:227: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <test_pytest_mock.TestMockerStub instance at 0x7f3916d29b48> mocker = <pytest_mock.MockFixture object at 0x7f3916efc4d0> kwargs = {'name': 'The Castle of aaarrrrggh'} expected_name = 'The Castle of aaarrrrggh' msg = 'Expected call: {0}()\nNot called' expected_message = 'Expected call: The Castle of aaarrrrggh()\nNot called' stub = <MagicMock name='The Castle of aaarrrrggh' spec='function' id='139883174676176'> exc_info = <ExceptionInfo AssertionError tblen=3> @py_assert2 = AssertionError(u'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.' def __test_failure_message(self, mocker, **kwargs): expected_name = kwargs.get("name") or "mock" if PY38: msg = "expected call not found.\nExpected: {0}()\nActual: not called." else: msg = "Expected call: {0}()\nNot called" expected_message = msg.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:220: AssertionError _________________________ test_detailed_introspection __________________________ testdir = <Testdir local('/tmp/pytest-of-mockbuild/pytest-0/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") if PY38: expected_lines = [ "*AssertionError: expected call not found.", "*Expected: mock('', bar=4)", "*Actual: mock('fo')", ] else: expected_lines = [ "*AssertionError: Expected call: mock('', bar=4)*", "*Actual call: mock('fo')*", ] expected_lines += [ "*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*", ] > result.stdout.fnmatch_lines(expected_lines) E Failed: nomatch: "*AssertionError: Expected call: mock('', bar=4)*" E and: u'============================= test session starts ==============================' E and: u'platform linux2 -- Python 2.7.16, pytest-4.4.1, py-1.8.0, pluggy-0.11.0' E and: u'rootdir: /tmp/pytest-of-mockbuild/pytest-0/test_detailed_introspection0' E and: u'plugins: mock-1.10.4' E and: u'collected 1 item' E and: u'' E and: u'test_detailed_introspection.py F' E and: u'' E and: u'=================================== FAILURES ===================================' E and: u'_____________________________________ test _____________________________________' E anderror: Bad exit status from /var/tmp/rpm-tmp.OTjS7u (%check) : u'' E and: u'mocker = <pytest_mock.MockFixture object at 0x7f3916dde050>' E and: u'' E and: u' def test(mocker):' E and: u' m = mocker.Mock()' E and: u" m('fo')" E and: u"> m.assert_called_once_with('', bar=4)" E and: u'E AssertionError: expected call not found.' E and: u"E Expected: mock('', bar=4)" E and: u"E Actual: mock('fo')" E and: u'E ' E and: u'E pytest introspection follows:' E and: u'E ' E and: u'E Args:' E and: u"E assert ('fo',) == ('',)" E and: u"E At index 0 diff: 'fo' != ''" E and: u'E Use -v to get the full diff' E and: u'E Kwargs:' E and: u"E assert {} == {'bar': 4}" E and: u'E Right contains more items:' E and: u"E {'bar': 4}" E and: u'E Use -v to get the full diff' E and: u'' E and: u'test_detailed_introspection.py:4: AssertionError' E and: u'=========================== 1 failed in 0.01 seconds ===========================' E and: u'' E remains unmatched: "*AssertionError: Expected call: mock('', bar=4)*" /builddir/build/BUILD/pytest-mock-1.10.4/test_pytest_mock.py:646: Failed ----------------------------- Captured stdout call ----------------------------- ============================= test session starts ============================== platform linux2 -- Python 2.7.16, pytest-4.4.1, py-1.8.0, pluggy-0.11.0 rootdir: /tmp/pytest-of-mockbuild/pytest-0/test_detailed_introspection0 plugins: mock-1.10.4 collected 1 item test_detailed_introspection.py F =================================== FAILURES =================================== _____________________________________ test _____________________________________ mocker = <pytest_mock.MockFixture object at 0x7f3916dde050> 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 =========================== =========================== short test summary info ============================ SKIPPED [1] test_pytest_mock.py:580: Py3 only XFAIL test_pytest_mock.py::test_class_method_subclass_spy does not work on Python 2 XFAIL test_pytest_mock.py::test_static_method_subclass_spy does not work on Python 2 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, 41 passed, 1 skipped, 2 xfailed in 2.17 seconds =========== *** This bug has been marked as a duplicate of bug 1732702 *** |