[TIP] pytest: markers as functions

Alexander Steinert stony8de at gmail.com
Sat Jan 26 05:08:53 PST 2013


Dear pytest users and maintainers,

my ideal custom marker definition/registration would look like this in
conftest.py:

@pytest.marker
def name(request, parg0, ..., kwarg0="default", ...):
    """marker documentation"""
    assert ..., "Mark args not used correctly"

The decorator would be in charge of registration (instead of pytest.ini).

The function would be called at collection time for each marking.

The request param could be used for collecting meta data that could be
retrieved later. Example:

@pytest.marker
def verifies(request, requirement):
    ....

....

@verifies("Requirement 42")
def test_42():
    assert False

....

$ py.test . --show-verifications
test_42 vierifies Requirement 42

By reading the fine manual I assume that this would be a feature request.
What would come closest to it using the current pytest?

TIA
Stony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20130126/fe78748d/attachment.html>


More information about the testing-in-python mailing list