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

Support doctest_global_setup #23

Open
twmr opened this issue Apr 22, 2020 · 2 comments
Open

Support doctest_global_setup #23

twmr opened this issue Apr 22, 2020 · 2 comments

Comments

@twmr
Copy link
Owner

twmr commented Apr 22, 2020

The doctest plugin in sphinx support specifying a code block in conf.py that is called at setup time

doctest_global_setup = '''
try:
    import pandas as pd
except ImportError:
    pd = None
'''

Support for specifying this code block somewhere should be added.

It can't be added to pytest.ini, because AFAIK it (or ini files in general) doesn't have support for multiline values. So probably it needs to be set in conftest.py. If anyone know how this can be done - please comment.

@twmr
Copy link
Owner Author

twmr commented Apr 22, 2020

This is already supported by pytest, see https://docs.pytest.org/en/latest/doctest.html#doctest-namespace-fixture

twmr added a commit that referenced this issue Apr 27, 2020
@twmr
Copy link
Owner Author

twmr commented May 1, 2020

I created a ticket, where I asked about implementation details of this feature in pytest-dev/pytest#7140

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

No branches or pull requests

1 participant