fixture¶
Test fixtures.
New in version 1.3.
- class oslo_utils.fixture.TimeFixture(override_time=None)¶
A fixture for overriding the time returned by timeutils.utcnow().
- Parameters:
override_time – datetime instance or list thereof. If not given, defaults to the current UTC time.
- advance_time_delta(timedelta)¶
Advance overridden time using a datetime.timedelta.
- advance_time_seconds(seconds)¶
Advance overridden time by seconds.
- setUp()¶
Prepare the Fixture for use.
This should not be overridden. Concrete fixtures should implement _setUp. Overriding of setUp is still supported, just not recommended.
After setUp has completed, the fixture will have one or more attributes which can be used (these depend totally on the concrete subclass).
- Raises:
MultipleExceptions if _setUp fails. The last exception captured within the MultipleExceptions will be a SetupError exception.
- Returns:
None.
- Changed in 1.3:
The recommendation to override setUp has been reversed - before 1.3, setUp() should be overridden, now it should not be.
- Changed in 1.3.1:
BaseException is now caught, and only subclasses of Exception are wrapped in MultipleExceptions.