Other plugins¶
Envinfo¶
Envinfo plugin adds some details to test report header
args: python3 -m pytest -vv -x
hostname: machine-hostname
git: branch current_branch, commit_hash*, base base_commit_hash
In git: section
*indicates uncommitted changesbase_commit_hashpoints to a commit indevelopbranch from which the current branch diverges
To use envinfo plugin, add it to pytest_plugins in conftest.py
pytest_plugins = [
# ...
'testsuite.envinfo',
]
Retrieving git status can be slow in docker due to network-related issues.
If it affects you, turn git status off by --envinfo-no-git flag.
Mocked_time¶
Fixtures¶
mocked_time fixture provides control over mock time in a centralized way.
Disabling mocked_time¶
mocked-time-enabled = falseflag inpytest.inidisables mocked time by default.--service-runner-modecommand line flag disables mocked time by default.
When mocked time is disabled by default, it has to explicitly enabled to be
used in a particular test: @pytest.mark.now('2016-12-01T12:00:00') or
@pytest.mark.now(enabled=True).
If time is not specified in @pytest.mark.now, then
current time at UTC timezone is used at the start of test as time value
until it is modified by calling mocked_time.set(...) or
mocked_time.sleep(...)
Timezones¶
Mocked time is always stored as offset-naive datetime in UTC timezone.
mocked_time.set(...) treats offset-naive datetime as datetime in UTC timezone
and converts offset-aware datetime to offset-naive automatically.
mocked_time.now() returns returns offset-naive datetime by default,
but with tz arg it will return offset-aware datetime in tz timezone.