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 config for enabling rst #49

Open
jayvdb opened this issue Sep 6, 2019 · 4 comments
Open

Add config for enabling rst #49

jayvdb opened this issue Sep 6, 2019 · 4 comments

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Sep 6, 2019

It would be helpful to have an easy way to include *.rst by default, without (ab)using addopts.

https://pypi.org/project/pytest-doctestplus/ provides this.

@Erotemic
Copy link
Owner

Erotemic commented Sep 7, 2019

This is a reasonable request.

Do you mainly want to use it via the pytest runner, or would you want the native runner to support this as well?

@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 7, 2019

My only interest is usage via pytest.

@Erotemic
Copy link
Owner

Erotemic commented Sep 9, 2019

Looking into this I found that you can use --xdoctest-glob *.rst, but this causes the document to be parsed as a text file and as such only lines prefixed with >>> are parsed. I assume this isn't what you want to happen.

I think it would be good to define the desired behavior a bit more precisely, because right now I'm unsure.

Are we only looking to support blocks of code that look like this:

.. code-block:: python

    >>> import foo
    >>> foo.bar()

or would we want to run all code snippets? How should we deal with something like this?

.. code:: python


    def func1():
        """
        Example:
            >>> assert func1() == 1
        """
        return 1

@jayvdb
Copy link
Contributor Author

jayvdb commented Sep 9, 2019

that is no different to

>>> def func1():
>>>     """
>>>     Example:
>>>         >>> assert func1() == 1
>>>     """
>>>     return 1

doctest ignores nested doctest.
See PyCQA/pyflakes@6734c37 and PyCQA/pyflakes@93aa3c4 for some more unusual scenarios and indicating what doctest does/doesnt process.

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

2 participants