datalad_next.tests.skipif_no_network
- datalad_next.tests.skipif_no_network = MarkDecorator(mark=Mark(name='skipif', args=(False,), kwargs={'reason': 'DATALAD_TESTS_NONETWORK is set'}))
A decorator for applying a mark on test functions and classes.
MarkDecorators
are created withpytest.mark
:mark1 = pytest.mark.NAME # Simple MarkDecorator mark2 = pytest.mark.NAME(name1=value) # Parametrized MarkDecorator
and can then be applied as decorators to test functions:
@mark2 def test_function(): pass
When a
MarkDecorator
is called, it does the following:If called with a single class as its only positional argument and no additional keyword arguments, it attaches the mark to the class so it gets applied automatically to all test cases found in that class.
If called with a single function as its only positional argument and no additional keyword arguments, it attaches the mark to the function, containing all the arguments already stored internally in the
MarkDecorator
.When called in any other case, it returns a new
MarkDecorator
instance with the originalMarkDecorator
's content updated with the arguments passed to this call.
Note: The rules above prevent a
MarkDecorator
from storing only a single function or class reference as its positional argument with no additional keyword or positional arguments. You can work around this by using with_args().