- class oslo_service.fixture.SleepFixture¶
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
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.
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) ...