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

Repeat decorator #16

Closed
Peque opened this issue Jul 21, 2017 · 10 comments
Closed

Repeat decorator #16

Peque opened this issue Jul 21, 2017 · 10 comments

Comments

@Peque
Copy link
Contributor

Peque commented Jul 21, 2017

Is it currently possible to mark a test with a decorator to be run multiple times?

In example:

@pytest.repeat(10)
def test_repeated_10():
    assert True

So when executing pytest only the tests that are marked with the decorator are run multiple times.

@The-Compiler
Copy link
Member

I see you opened #16 already - I think this definitely should go to that plugin rather than pytest core.

@The-Compiler
Copy link
Member

Argh! Nevermind me. I thought this was the core repository, my bad! 😆

@The-Compiler The-Compiler reopened this Jul 21, 2017
@shreyashah
Copy link

Do we have this repeat decorator?

@RonnyPfannschmidt
Copy link
Member

no

@shreyashah
Copy link

any plans to bring it in?

@The-Compiler
Copy link
Member

This is all voluntary work, so if nobody steps up, nothing will happen 😉 Help welcome!

@nicoddemus
Copy link
Member

If anyone wants to tackle this, it should be just a matter of changing this part of the code:

def pytest_generate_tests(metafunc):
count = metafunc.config.option.count

To also get the mark from the metafunc.function object and use that if the mark is present:

def pytest_generate_tests(metafunc):
    count = metafunc.config.option.count
    mark = metafunc.function.get_closest_mark('repeat')
    if mark:
        count = mark.args[0]
    ...

Plus tests and update the README.

(all the above is untested, but it shouldn't be far off)

@shreyashah
Copy link

Sure, let me try doing this and create a PR. Thanks.

@Peque
Copy link
Contributor Author

Peque commented Jul 12, 2018

See #22.

@shreyashah Hope you do not mind. 😊

@shreyashah
Copy link

@Peque : Oh absolutely, no! Thank you for bringing this in. I had this in my local env, but pushed to open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants