Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markers as functions #277

Closed
pytestbot opened this issue Mar 17, 2013 · 1 comment
Closed

Markers as functions #277

pytestbot opened this issue Mar 17, 2013 · 1 comment
Labels
type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Alexander Steinert (BitBucket: stony8, GitHub: stony8)


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.


@pytestbot pytestbot added the type: enhancement new feature or API change, should be merged into features branch label Jun 15, 2015
pytestbot pushed a commit that referenced this issue Jun 15, 2015
This removes the drone.io badge from the README as it doesn't make
sense to have it on the cheeseshop status page.

Fixes issue #726.
@RonnyPfannschmidt
Copy link
Member

closing as the patch still is not provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

2 participants