Comment 22 for bug 1735588

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

Reviewed: https://review.openstack.org/561581
Committed: https://git.openstack.org/cgit/openstack/oslotest/commit/?id=8241dd624f8ca481fe15a44f7d3fed10be7ae937
Submitter: Zuul
Branch: master

commit 8241dd624f8ca481fe15a44f7d3fed10be7ae937
Author: Claudiu Belu <email address hidden>
Date: Fri Apr 13 10:33:12 2018 -0700

    mock: Perform patch's autospec checks on __enter__

    Currently we're doing the autospec checks on __init__ (if the
    target is autospecable), which will require importing modules
    in some cases.

    The mock.patch's constructor is called when a test module is being
    loaded, before any set up could have been run, which can be problematic
    in some cases (e.g.: some tested modules are importing platform specific
    modules, and they couldn't have been mocked yet).

    This patch moves the autospec checks to __enter__, which is executed
    after the setUp.

    Related-Bug: #1735588

    Change-Id: I9e10b34092ad795c7f9e58596fcccf4f37856225