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#

@pytest.mark.skip_if_not_root#

Skip the test if the user running the test suite is not root or Administrator on Windows.

@pytest.mark.skip_if_not_root
def test_func():
    assert True

Look here for the full function signature.

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 is True, the default, all binaries must exist. If check_all is False, 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#

@pytest.mark.skip_on_windows(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on windows.

@pytest.mark.skip_on_windows
def test_func():
    assert True

skip_unless_on_windows#

@pytest.mark.skip_unless_on_windows(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on windows.

@pytest.mark.skip_unless_on_windows
def test_func():
    assert True

skip_on_linux#

@pytest.mark.skip_on_linux(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on linux.

@pytest.mark.skip_on_linux
def test_func():
    assert True

skip_unless_on_linux#

@pytest.mark.skip_unless_on_linux(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on linux.

@pytest.mark.skip_unless_on_linux
def test_func():
    assert True

skip_on_darwin#

@pytest.mark.skip_on_darwin(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on darwin.

@pytest.mark.skip_on_darwin
def test_func():
    assert True

skip_unless_on_darwin#

@pytest.mark.skip_unless_on_darwin(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on darwin.

@pytest.mark.skip_unless_on_darwin
def test_func():
    assert True

skip_on_sunos#

@pytest.mark.skip_on_sunos(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on sunos.

@pytest.mark.skip_on_sunos
def test_func():
    assert True

skip_unless_on_sunos#

@pytest.mark.skip_unless_on_sunos(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on sunos.

@pytest.mark.skip_unless_on_sunos
def test_func():
    assert True

skip_on_smartos#

@pytest.mark.skip_on_smartos(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on smartos.

@pytest.mark.skip_on_smartos
def test_func():
    assert True

skip_unless_on_smartos#

@pytest.mark.skip_unless_on_smartos(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on smartos.

@pytest.mark.skip_unless_on_smartos
def test_func():
    assert True

skip_on_freebsd#

@pytest.mark.skip_on_freebsd(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on freebsd.

@pytest.mark.skip_on_freebsd
def test_func():
    assert True

skip_unless_on_freebsd#

@pytest.mark.skip_unless_on_freebsd(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on freebsd.

@pytest.mark.skip_unless_on_freebsd
def test_func():
    assert True

skip_on_netbsd#

@pytest.mark.skip_on_netbsd(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on netbsd.

@pytest.mark.skip_on_netbsd
def test_func():
    assert True

skip_unless_on_netbsd#

@pytest.mark.skip_unless_on_netbsd(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on netbsd.

@pytest.mark.skip_unless_on_netbsd
def test_func():
    assert True

skip_on_openbsd#

@pytest.mark.skip_on_openbsd(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on openbsd.

@pytest.mark.skip_on_openbsd
def test_func():
    assert True

skip_unless_on_openbsd#

@pytest.mark.skip_unless_on_openbsd(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on openbsd.

@pytest.mark.skip_unless_on_openbsd
def test_func():
    assert True

skip_on_aix#

@pytest.mark.skip_on_aix(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on aix.

@pytest.mark.skip_on_aix
def test_func():
    assert True

skip_unless_on_aix#

@pytest.mark.skip_unless_on_aix(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on aix.

@pytest.mark.skip_unless_on_aix
def test_func():
    assert True

skip_on_aarch64#

@pytest.mark.skip_on_aarch64(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on aarch64.

@pytest.mark.skip_on_aarch64
def test_func():
    assert True

skip_unless_on_aarch64#

@pytest.mark.skip_unless_on_aarch64(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is running on aarch64.

@pytest.mark.skip_unless_on_aarch64
def test_func():
    assert True

skip_on_spawning_platform#

@pytest.mark.skip_on_spawning_platform(reason=None)#
Parameters

reason (str) – The skip reason

Skip test if test suite is running on a platfor which defaults multiprocessing to spawn.

@pytest.mark.skip_on_spawning_platform
def test_func():
    assert True

skip_unless_on_spawning_platform#

@pytest.mark.skip_unless_on_spawning_platform(reason=None)#
Parameters

reason (str) – The skip reason

Skip test unless the test suite is not running on a platform which defaults multiprocessing to spawn.

@pytest.mark.skip_unless_on_spawning_platform
def test_func():
    assert True

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 if True

  • 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 if True

  • 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