Comment 21 for bug 1735588

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

Reviewed: https://review.openstack.org/557923
Committed: https://git.openstack.org/cgit/openstack/oslotest/commit/?id=6baff0eda4edbd8163426a2ac774514cabf99a3a
Submitter: Zuul
Branch: master

commit 6baff0eda4edbd8163426a2ac774514cabf99a3a
Author: Claudiu Belu <email address hidden>
Date: Thu Mar 29 04:57:48 2018 -0700

    mock: Apply autospec to a mock's return_value

    When creating a mock with a class as an autospec:

    mock_foo = mock.Mock(autospec=FooClass)

    The autospec is only applied to mock_foo itself, and it will
    behave as expected. However, the autospec is not applied to its
    return_value and thus, the method validation is not enforced:

    mock_foo().lish(some_argument_which_doesnt_exist=42)

    This patch addresses this issue, and adds necessary unit tests to
    test this behaviour.

    Change-Id: Icd96beba5a32001cf33f075b801471c6e7c75898
    Related-Bug: #1735588