00f20ab1d481342b7297df14f5ff42a31c185469
In Python, when we use @property, the method will be decorated by property. When we call method self.strategy.datasource_backend()[1], Actually it did two things: 1. call self.strategy.datasource_backend() 2. according to the method's return value[2], call self._datasource_backend() [1]. https://github.com/openstack/watcher/blob/bd8636f3f/watcher/tests/decision_engine/strategy/strategies/test_base.py#L87 [2]. https://github.com/openstack/watcher/blob/bd8636f3f/watcher/decision_engine/strategy/strategies/base.py#L368 But in this part, we just want it to perform the first step. So we have to use self.strategy.datasource_backend instead of self.strategy.datasource_backend() The reason why the unittest does not report an error is because the returned value is a mock object, and the second step is executed without error, for example: python -m unittest watcher.tests.decision_engine.strategy.strategies.test_base (Pdb) x=self.strategy.datasource_backend (Pdb) type(x) <class 'mock.mock.MagicMock'> (Pdb) x <MagicMock name='DataSourceManager().get_backend()' id='139740418102608'> (Pdb) x() <MagicMock name='DataSourceManager().get_backend()()' id='139740410824976'> (Pdb) self.strategy.datasource_backend() <MagicMock name='DataSourceManager().get_backend()()' id='139740410824976'> To make the tests more robust, the underlying backend function is mocked to be not callable. Co-Authored-By: Matt Riedemann <mriedem.os@gmail.com> Change-Id: I3305d9afe8ed79e1dc3affe02ba067ac06cece42
========================
Team and repository tags
========================
.. image:: https://governance.openstack.org/tc/badges/watcher.svg
:target: https://governance.openstack.org/tc/reference/tags/index.html
.. Change things from this point on
..
Except where otherwise noted, this document is licensed under Creative
Commons Attribution 3.0 License. You can view the license at:
https://creativecommons.org/licenses/by/3.0/
=======
Watcher
=======
OpenStack Watcher provides a flexible and scalable resource optimization
service for multi-tenant OpenStack-based clouds.
Watcher provides a robust framework to realize a wide range of cloud
optimization goals, including the reduction of data center
operating costs, increased system performance via intelligent virtual machine
migration, increased energy efficiency and more!
* Free software: Apache license
* Wiki: https://wiki.openstack.org/wiki/Watcher
* Source: https://opendev.org/openstack/watcher
* Bugs: https://bugs.launchpad.net/watcher
* Documentation: https://docs.openstack.org/watcher/latest/
* Release notes: https://docs.openstack.org/releasenotes/watcher/
Description
Languages
Python
99.7%
Shell
0.3%