--- you can reply above this line --- New issue 277: Markers as functions https://bitbucket.org/hpk42/pytest/issue/277/markers-as-functions
Alexander Steinert: Scattering a custom marker registration/defintion/usage to different hook functions -- like done in http://pytest.org/latest/example/markers.html#custom-marker-and-command-line-option-to-control-test-runs -- does not scale well to multiple markers. I would prefer to define a custom marker as a function that gets called at collection time for each marked test. Example: ``` #!python import re import pytest @pytest.marker def verifies(requirement): """mark test as verifying a requirement""" assert re.search(r"^http://myjira/browse/PROJ-\d+$", requirement) @pytest.mark.verifies("http://myjira/browse/PROJ-42") def test_42(): assert 6 * 8 != 42 ``` With the decorator pytest.marker we could avoid calling config.addinivalue_line("markers", ...) and be able to check marker arguments. The arguments should be available in hooks, e.g. ``` #!python item.keywords["verifies"].getarg("requirement"). ``` Holger has an unfinished patch which allows roughly the above. His decorator is called pytest.markdefinition. I would prefer pytest.marker but thats just a matter of taste. -- This is an issue notification from bitbucket.org. You are receiving this either because you are the owner of the issue, or you are following the issue. _______________________________________________ pytest-commit mailing list pytest-commit@python.org http://mail.python.org/mailman/listinfo/pytest-commit