Bases: fixtures.fixture.Fixture
A fixture for mocking the wait()
within loopingcall events.
This exists so test cases can exercise code that uses loopingcall without actually incurring wall clock time for sleeping.
The mock for the wait()
is accessible via the fixture’s mock_wait
attribute.
Note
It is not recommended to assert specific arguments (i.e. timeout values) to the mock, as this relies on the internals of loopingcall not changing.
Example usage:
from oslo.service import fixture
...
class MyTest(...):
def setUp(self):
...
self.sleepfx = self.useFixture(fixture.SleepFixture())
...
def test_this(self):
...
thing_that_hits_a_loopingcall()
...
self.assertEqual(5, self.sleepfx.mock_wait.call_count)
...
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.