pytest-repeat crashes on doctest
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:
https://github.com/pytest-dev/pytest-repeat/blob/c74dd59ebceda1c7963cde1935a57c498bc565bf/pytest_repeat.py#L42
Happy to open a PR
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.
Related: https://github.com/pytest-dev/pytest/issues/5070 (I guess) Please also try master (https://github.com/pytest-dev/pytest-repeat/commit/c74dd59ebceda1c7963cde1935a57c498bc565bf might fix/improve the situation).
on master it just fails silently, and doctests don't get run multiple times. its an improvement over crashing at least
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.
we should document that this doesn't work