test_mock_patch_manually failing on py27

Bug #1830429 reported by Ben Nemec
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslotest
Fix Released
High
Ben Nemec

Bug Description

oslotest.tests.unit.test_base.TestManualMock.test_mock_patch_manually
---------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "oslotest/tests/unit/test_base.py", line 135, in tearDown
        self.unstopped.stop,
      File "/home/fedora/oslotest/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 485, in assertRaises
        self.assertThat(our_callable, matcher)
      File "/home/fedora/oslotest/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: <bound method _patch.stop of <oslotest.mock_fixture._patch object at 0x7f993e260b10>> returned None

I'm a little confused by this test, but I don't see why it would fail on py2 and not py3 all of a sudden.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslotest (master)

Fix proposed to branch: master
Review: https://review.opendev.org/661816

Changed in oslotest:
assignee: nobody → Ben Nemec (bnemec)
status: Confirmed → In Progress
Revision history for this message
Ben Nemec (bnemec) wrote :

Looks like this was broken in the mock 3.0.0 release, which explains why it only fails on py27. Further, according to the changelog this was an intentional behavior change: "Issue #36366: Calling stop() on an unstarted or stopped unittest.mock.patch() object will now return None instead of raising RuntimeError, making the method idempotent. Patch byKarthikeyan Singaravelan."

We should just stop testing mock this way. It isn't our job to verify their behavior.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslotest (master)

Reviewed: https://review.opendev.org/661816
Committed: https://git.openstack.org/cgit/openstack/oslotest/commit/?id=f8f6b14088637fd87de7cf385b840d6b5e5f9b22
Submitter: Zuul
Branch: master

commit f8f6b14088637fd87de7cf385b840d6b5e5f9b22
Author: Ben Nemec <email address hidden>
Date: Tue May 28 17:04:19 2019 +0000

    Stop testing mock functionality

    There's no particular reason for us to be verifying mock's behavior.
    They have their own unit tests for doing that.

    This is specifically a problem right now because mock changed its
    behavior in 3.0.0 and broke this test: "Issue #36366: Calling stop()
    on an unstarted or stopped unittest.mock.patch() object will now
    return None instead of raising RuntimeError, making the method
    idempotent."

    Change-Id: I57db9bad15cab343e152615e115e2ba3ac4d87fe
    Closes-Bug: 1830429

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

This issue was fixed in the openstack/oslotest 3.8.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslotest (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/672522

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslotest (stable/stein)

Reviewed: https://review.opendev.org/672522
Committed: https://git.openstack.org/cgit/openstack/oslotest/commit/?id=9e46577ab812cd4657b6ca276f0061c1851d2925
Submitter: Zuul
Branch: stable/stein

commit 9e46577ab812cd4657b6ca276f0061c1851d2925
Author: Ben Nemec <email address hidden>
Date: Tue May 28 17:04:19 2019 +0000

    Stop testing mock functionality

    There's no particular reason for us to be verifying mock's behavior.
    They have their own unit tests for doing that.

    This is specifically a problem right now because mock changed its
    behavior in 3.0.0 and broke this test: "Issue #36366: Calling stop()
    on an unstarted or stopped unittest.mock.patch() object will now
    return None instead of raising RuntimeError, making the method
    idempotent."

    Change-Id: I57db9bad15cab343e152615e115e2ba3ac4d87fe
    Closes-Bug: 1830429
    (cherry picked from commit f8f6b14088637fd87de7cf385b840d6b5e5f9b22)

tags: added: in-stable-stein
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.