class oslo_service.fixture.SleepFixture

Bases: 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.


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):
        self.assertEqual(5, self.sleepfx.mock_wait.call_count)