Tests failing due to mock 3.0.0

Bug #1831870 reported by Stephen Finucane
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ec2-api
Fix Released
Undecided
Stephen Finucane

Bug Description

Two of the unit tests are currently failing on all branches:

    $ tox -e py27
    ...
    ==============================
    Failed 2 tests - output below:
    ==============================

    ec2api.tests.unit.test_vpn_gateway.VpnGatewayTestCase.test_attach_vpn_gateway
    -----------------------------------------------------------------------------

    Captured traceback:
    ~~~~~~~~~~~~~~~~~~~
        Traceback (most recent call last):
          File "/home/sfinucan/Development/openstack/ec2-api/.tox/py27/lib/python2.7/site-packages/mock/mock.py", line 1330, in patched
            return func(*args, **keywargs)
          File "ec2api/tests/unit/test_vpn_gateway.py", line 112, in test_attach_vpn_gateway
            do_check()
          File "ec2api/tests/unit/test_vpn_gateway.py", line 88, in do_check
            self.assertEqual(2, self.db_api.update_item.call_count)
          File "/home/sfinucan/Development/openstack/ec2-api/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
            self.assertThat(observed, matcher, message)
          File "/home/sfinucan/Development/openstack/ec2-api/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
            raise mismatch_error
        testtools.matchers._impl.MismatchError: 2 != 1

    ec2api.tests.unit.test_vpn_gateway.VpnGatewayTestCase.test_detach_vpn_gateway
    -----------------------------------------------------------------------------

    Captured traceback:
    ~~~~~~~~~~~~~~~~~~~
        Traceback (most recent call last):
          File "/home/sfinucan/Development/openstack/ec2-api/.tox/py27/lib/python2.7/site-packages/mock/mock.py", line 1330, in patched
            return func(*args, **keywargs)
          File "ec2api/tests/unit/test_vpn_gateway.py", line 250, in test_detach_vpn_gateway
            do_check()
          File "ec2api/tests/unit/test_vpn_gateway.py", line 221, in do_check
            self.assertEqual(3, self.db_api.update_item.call_count)
          File "/home/sfinucan/Development/openstack/ec2-api/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
            self.assertThat(observed, matcher, message)
          File "/home/sfinucan/Development/openstack/ec2-api/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
            raise mismatch_error
        testtools.matchers._impl.MismatchError: 3 != 2
    ...

This appears to be because of a change in behavior in mock 3.x. Manually downgrading to mock 2.0.0 in the py27 venv resolves this issue.

Changed in ec2-api:
status: New → Confirmed
assignee: nobody → Stephen Finucane (stephenfinucane)
Changed in ec2-api:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ec2-api (master)

Reviewed: https://review.opendev.org/663651
Committed: https://git.openstack.org/cgit/openstack/ec2-api/commit/?id=7b7c2d9f213d6c147b81e0a62ec0bdd907721080
Submitter: Zuul
Branch: master

commit 7b7c2d9f213d6c147b81e0a62ec0bdd907721080
Author: Stephen Finucane <email address hidden>
Date: Thu Jun 6 11:15:45 2019 +0100

    tests: Avoid using mock wraps

    It looks like something has changed in mock 3.x, resulting in some
    functions that are wrapped by mock not being called or being called
    incorrectly. This breaks some of the assertions we have. There is almost
    certainly a bug (or is it a feature, who knows) but the fact is these
    tests were extremely tightly coupled to the implementation and probably
    didn't need to be. Stop attempting to spy on them and resolve the issue.

    We also start using 'assert_not_called' since that's available in mock
    3.x.

    Change-Id: I06dddc4eba36f80398732ab4f2b7cbc4d7717a00
    Signed-off-by: Stephen Finucane <email address hidden>
    Closes-Bug: #1831870

Changed in ec2-api:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/ec2-api 9.0.0.0rc1

This issue was fixed in the openstack/ec2-api 9.0.0.0rc1 release candidate.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.