Markers#
destructive_test
#
- @pytest.mark.destructive_test#
Skip the test if
--run-destructive
is not passed to pytest on the CLI.Use this mark when the test does something destructive to the system where the tests are running, for example, adding or removing a user, changing a user password.
Note
Do not use this marker if all the test does is add/remove/change files in the test suite temporary directory
@pytest.mark.destructive_test def test_func(): assert True
expensive_test
#
- @pytest.mark.expensive_test#
Skip the test if
--run-expensive
is not passed to pytest on the CLI.Use this test when the test does something expensive(as in monetary expensive), like creating a virtual machine on a cloud provider, etc.
@pytest.mark.expensive_test def test_func(): assert True
skip_if_not_root
#
skip_if_binaries_missing
#
- @pytest.mark.skip_if_binaries_missing(\*binaries, check_all=True, reason=None)#
- Parameters
binaries (str) – Any argument passed must be a
str
which is the name of the binary check for presence in the path. Multiple arguments can be passed.check_all (bool) – If
check_all
isTrue
, the default, all binaries must exist. Ifcheck_all
isFalse
, then only one the passed binaries needs to be found. Useful when, for example, passing a list of python interpreter names(python3.5, python3, python), where only one needs to exist.reason (str) – The skip reason.
Skip tests if binaries are not found in path.
@pytest.mark.skip_if_binaries_missing("sshd") def test_func(): assert True @pytest.mark.skip_if_binaries_missing("python3.7", "python3", "python", check_all=False) def test_func(): assert True
Look
here
for the full function signature.
requires_network
#
skip_on_windows
#
skip_unless_on_windows
#
skip_on_linux
#
skip_unless_on_linux
#
skip_on_darwin
#
skip_unless_on_darwin
#
skip_on_sunos
#
skip_unless_on_sunos
#
skip_on_smartos
#
skip_unless_on_smartos
#
skip_on_freebsd
#
skip_unless_on_freebsd
#
skip_on_netbsd
#
skip_unless_on_netbsd
#
skip_on_openbsd
#
skip_unless_on_openbsd
#
skip_on_aix
#
skip_unless_on_aix
#
skip_on_aarch64
#
skip_unless_on_aarch64
#
skip_on_spawning_platform
#
skip_unless_on_spawning_platform
#
skip_on_platforms
#
- @pytest.mark.skip_on_platforms(**platforms, reason=None)#
- Parameters
windows (bool) – Skip on windows if
True
linux (bool) – Skip on linux if
True
darwin (bool) – Skip on darwin if
True
sunos (bool) – Skip on sunos if
True
smartos (bool) – Skip on smartos if
True
freebsd (bool) – Skip on freebsd if
True
netbsd (bool) – Skip on netbsd if
True
openbsd (bool) – Skip on openbsd if
True
aix (bool) – Skip on aix if
True
aarch64 (bool) – Skip on aarch64 if
True
spawning (bool) – Skip on platforms for which multiprocessing defaults to
spawn
ifTrue
reason (str) – The skip reason
Pass
True
to any of the platforms defined as keyword arguments to skip the test when running on that platform@pytest.mark.skip_on_platforms(windows=True, darwin=True) def test_func(): assert True
skip_unless_on_platforms
#
- @pytest.mark.skip_unless_on_platforms(**platforms, reason=None)#
- Parameters
windows (bool) – Skip unless on windows if
True
linux (bool) – Skip unless on linux if
True
darwin (bool) – Skip unless on darwin if
True
sunos (bool) – Skip unless on sunos if
True
smartos (bool) – Skip unless on smartos if
True
freebsd (bool) – Skip unless on freebsd if
True
netbsd (bool) – Skip unless on netbsd if
True
openbsd (bool) – Skip unless on openbsd if
True
aix (bool) – Skip unless on aix if
True
aarch64 (bool) – Skip on aarch64 if
True
spawning (bool) – Skip on platforms for which multiprocessing does not default to
spawn
ifTrue
reason (str) – The skip reason
Pass
True
to any of the platforms defined as keyword arguments to skip the test when not running on that platform@pytest.mark.skip_unless_on_platforms(windows=True, darwin=True) def test_func(): assert True