nova/nova/tests/unit/storage
Balazs Gibizer 930b7c9921 Avoid modifying the Mock class in test
The rdb unit test defines a shutdown field on the Mock class
unintentionally. This causes that a later test in the same
executor expecting that mock.Mock().shutdown is a newly auto
generated mock.Mock() but it founds that is an already used
(called) object. This causes that the later test fails when
asserting the number of calls on that mock.

The original intention of the rbd unit test was to catch the
instantiation of the Rados object in test so it set Rados = mock.Mock()
so when the code under test called Rados() it actually called Mock().
It worked but it has that huge side effect. Instead of this a proper
mocking of the constructor can be done in two steps:

rados_inst = mock.Mock()
Rados = mock.Mock(return_value=rados_inst)

This makes sure that every Rados() call will return rados_inst that is a
mock without causing Mock class level side effect.

Change-Id: If71620e808744736cb4fe3abda76d81a6335311b
Closes-Bug: #1936849
2021-08-23 17:36:00 +02:00
..
__init__.py rbd: Get rbd_utils unit tests running again 2021-05-10 19:18:30 +00:00
test_rbd.py Avoid modifying the Mock class in test 2021-08-23 17:36:00 +02:00