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

pytest-repeat crashes on doctest #41

Open
brianmaissy opened this issue Nov 11, 2019 · 5 comments
Open

pytest-repeat crashes on doctest #41

brianmaissy opened this issue Nov 11, 2019 · 5 comments

Comments

@brianmaissy
Copy link

brianmaissy commented Nov 11, 2019

on python 3.6.8, pytest 4.5.0, pytest-repeat 0.8.0

py.test --doctest-modules --count=2

    @pytest.fixture(autouse=True)
    def __pytest_repeat_step_number(request):
        if request.config.option.count > 1:
            try:
                return request.param
            except AttributeError:
>               if issubclass(request.cls, TestCase):
E               TypeError: issubclass() arg 1 must be a class

When the test is a doctest (request.node is a DoctestItem), request.cls is None.

I assume this can be fixed with an extra is not None in the condition on line 42:

if issubclass(request.cls, TestCase):

Happy to open a PR

@brianmaissy
Copy link
Author

brianmaissy commented Nov 11, 2019

Hmm never mind it's a bit more complicated than that.

Looks like pytest_generate_tests isn't even called for doctest tests.

Let me know if you have any ideas, but if it's too complicated to be worth implementing I understand.

In any case fixing the issubclass call is probably a good idea, just so the error message would be more indicative:

pytest_repeat.UnexpectedError: This call couldn't work with pytest-repeat. Please consider raising an issue with your usage.

Maybe we could even check if it's a doctest and give an even more specific error.

@blueyed
Copy link
Contributor

blueyed commented Nov 11, 2019

Related: pytest-dev/pytest#5070 (I guess)
Please also try master (c74dd59 might fix/improve the situation).

@brianmaissy
Copy link
Author

on master it just fails silently, and doctests don't get run multiple times.
its an improvement over crashing at least

@nicoddemus
Copy link
Member

I assume this can be fixed with an extra is not None in the condition on line 42:

Seems like this makes sense either way, because param.cls might be None anytime a test is not defined in class.

@okken
Copy link
Contributor

okken commented Oct 6, 2023

we should document that this doesn't work

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

No branches or pull requests

4 participants