dandi.tests.skip

Define skipif and mark namespaces for custom pytest skippers.

There are two main ways to skip in pytest:

  • decorating a test function, such as:

    @pytest.mark.skip(sys.platform.startswith("win"), reason="on windows")
    def test_func():
        [...]
    
  • skipping inline, such as:

    def test_func():
        if sys.platform.startswith("win"):
            pytest.skip("on Windows")
        [...]
    

This module provides a mechanism to register a reason and condition as both a decorator and an inline function:

  • Within this module, create a condition function that returns a tuple of the form (REASON, COND). REASON is a str that will be shown as the reason for the skip, and COND is a boolean indicating if the test should be skipped.

    For example:

    def windows():
        return "on windows", sys.platform.startswith("win")
    
  • Then add the above function to CONDITION_FNS.

Doing that will make the skip condition available in two places: mark.skipif_NAME and skipif.NAME. So, for the above example, there would now be mark.skipif_windows and skipif.windows.

Functions

Classes

Mark()

Namespace for mark variants of the condition functions.

Namespace()

Provide namespace skip conditions in CONDITION_FNS.

SkipIf()

Namespace for inline variants of the condition functions.

Exceptions

NamespaceAttributeError

Namespace-specific AttributeError.

class dandi.tests.skip.Mark[source]

Namespace for mark variants of the condition functions.

Each condition is available under an attribute “skipif_NAME”, where NAME is the condition function name.

attr_value(condition_func)[source]

Given a condition function, return an attribute value.

class dandi.tests.skip.Namespace[source]

Provide namespace skip conditions in CONDITION_FNS.

abstract attr_value(condition_func)[source]

Given a condition function, return an attribute value.

fns = {'no_docker_commands': <function no_docker_commands>, 'no_docker_engine': <function no_docker_engine>, 'no_git': <function no_git>, 'no_network': <function no_network>, 'no_ssh': <function no_ssh>, 'on_windows': <function on_windows>}
exception dandi.tests.skip.NamespaceAttributeError[source]

Namespace-specific AttributeError.

Raised by Namespace when it cannot find the specified condition function. Using a derived class allows us to distinguish an unknown condition function from a condition function that raises an AttributeError.

class dandi.tests.skip.SkipIf[source]

Namespace for inline variants of the condition functions.

Each condition is available under an attribute with the same name as the condition function name.

attr_value(condition_func)[source]

Given a condition function, return an attribute value.

dandi.tests.skip.no_docker_commands()[source]
dandi.tests.skip.no_docker_engine()[source]
dandi.tests.skip.no_git()[source]
dandi.tests.skip.no_network()[source]
dandi.tests.skip.no_ssh()[source]
dandi.tests.skip.on_windows()[source]