Caution
This page documents the latest, unreleased version of Buildbot. For documentation for released versions, see http://docs.buildbot.net/current/.
2.5.25.2. TestReactorMixin
- class buildbot.test.reactor.TestReactorMixin
The class
TestReactorMixin
is used to create a faketwisted.internet.reactor
in tests. This allows to mock the flow of time in tests. The fake reactor becomes available asself.reactor
in the test case that mixes inTestReactorMixin
.Call
self.reactor.advance(seconds)
to advance the mocked time by the specified number of seconds.Call
self.reactor.pump(seconds_list)
to advance the mocked time multiple times as if by callingadvance
.For more information see the documentation of twisted.internet.task.Clock.
- setup_test_reactor(use_asyncio=False, auto_tear_down=True)
- Parameters:
use_asyncio (bool) – Whether to enable asyncio integration.
auto_tear_down (bool) – Whether to automatically tear down the test reactor. This option is deprecated in favor of
tear_down_test_reactor()
as the automatic tear down can only run beforetearDown()
and thus in many tests the test reactor is shut down prematurely.
Call this function in the
setUp()
of the test case to setup fake reactor.
- tear_down_test_reactor()
Call this function in the
tearDown()
of the test case to tear down fake reactor. The function returns aDeferred
.