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

Add support for markers in doctests #5794

Open
hmoravec opened this issue Aug 27, 2019 · 5 comments
Open

Add support for markers in doctests #5794

hmoravec opened this issue Aug 27, 2019 · 5 comments
Labels
plugin: doctests related to the doctests builtin plugin topic: marks related to marks, either the general marks or builtin type: enhancement new feature or API change, should be merged into features branch

Comments

@hmoravec
Copy link

hmoravec commented Aug 27, 2019

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

@Zac-HD Zac-HD added plugin: doctests related to the doctests builtin plugin topic: marks related to marks, either the general marks or builtin type: enhancement new feature or API change, should be merged into features branch labels Sep 13, 2019
@pandichef
Copy link

I second this. For example, I'd like to mark a doctest as @pytest.mark.slow. Is there any way to do this currently?

@mcepl
Copy link

mcepl commented Jan 15, 2022

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.

@nicoddemus
Copy link
Member

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.

@mcepl
Copy link

mcepl commented Jan 15, 2022

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!

@nicoddemus
Copy link
Member

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.

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

No branches or pull requests

5 participants