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
Reviewed: https:/ /review. openstack. org/557923 /git.openstack. org/cgit/ openstack/ oslotest/ commit/ ?id=6baff0eda4e dbd8163426a2ac7 74514cabf99a3a
Committed: https:/
Submitter: Zuul
Branch: master
commit 6baff0eda4edbd8 163426a2ac77451 4cabf99a3a
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: Icd96beba5a3200 1cf33f075b80147 1c6e7c75898
Related-Bug: #1735588