Add support for markers in doctests
It would be useful if also classes / methods / functions with doctests could be marked:
import pytest
@pytest.mark.custom_marker
def return_true():
"""Return True.
>>> return_true()
True
""""
return True
and then selected
$ pytest -m custom_marker
I second this. For example, I'd like to mark a doctest as @pytest.mark.slow. Is there any way to do this currently?
I third this. I work for SUSE and our package build environments are isolated from network (the same goes from obvious reasons for all package distributions, Linux or not), so it is quite common to mark some tests as @pytest.mark.network and then skip those tests with %pytest -k not network.
Something like this would be very helpful:
>>> Image('http://www.google.fr/images/srpr/logo3w.png') # doctest: +pytest.mark.network
as a parallel of # doctest: +SKIP.
I'm particularly 👎 on adding extra functionality to the doctests plugin that does not mirror a functionality in the standard library. I also don't find it appealing to use pytest functionality (pytest.mark) in production code.
I'm particularly -1 on adding extra functionality to the doctests plugin that does not mirror a functionality in the standard library. I also don't find it appealing to use pytest functionality (
pytest.mark) in production code.
I am glad you have your own idea how to do it. Please, do share!
I am glad you have your own idea how to do it. Please, do share!
Oh but I don't, sorry if I wasn't clear.
+1
I use doctests for all the examples in the documentation for python-statemachine. Some examples generate diagrams on disk. I want to skip those doctests and run them only before generating the documentation pages.