Skip to content

Include an example of how to skip all doctests in a module - #2310

Merged
embray merged 1 commit into
astropy:masterfrom
mdboom:tests/how-to-skip-all-doctests
Apr 23, 2014
Merged

embray merged 1 commit into
astropy:masterfrom
mdboom:tests/how-to-skip-all-doctests

Conversation

@mdboom

@mdboom mdboom commented Apr 11, 2014

Copy link
Copy Markdown
Contributor

As reported by @cdeil in the mailing list thread "How to skip entire files from being executed as doctests by the Astropy test runner?"

@mdboom mdboom modified the milestones: v0.4.0, v0.3.2 Apr 11, 2014
@cdeil

cdeil commented Apr 11, 2014

Copy link
Copy Markdown
Member

I want to skip an entire file, not just doctests in a file.
E.g. put a file kronka_lonka.py with content at the top level

import kronka_lonka

somewhere in the core astropy or an affiliated package and it will be found by the doctest runner and result in an ImportError.

My concrete issue is this: gammapy/gammapy#101

@mdboom

mdboom commented Apr 11, 2014

Copy link
Copy Markdown
Contributor Author

The way we typically deal with that in astropy itself is to not do those kinds of imports at the top level -- i.e. everything is importable by default. Unfortunately, the doctest runner has to import the file to determine if there are any doctests in it.

That said, there is the doctests_norecursedirs option that you can put in the [pytest] section of setup.cfg. It only works with directories, though.

@cdeil

cdeil commented Apr 11, 2014

Copy link
Copy Markdown
Member

Would it be hard to add a doctests_skipfiles option in addition to doctests_norecursedirs?
Having to create extra directories for the files I want skipped would be messy.

@mdboom

mdboom commented Apr 11, 2014

Copy link
Copy Markdown
Contributor Author

Not sure. Cc: @embray

@embray

embray commented Apr 11, 2014

Copy link
Copy Markdown
Member

Ah, right, in #1563 I added a bit so that the code that collects doctests from Python modules will just skip that module if it contains errors. Would that resolve the issue?

@cdeil

cdeil commented Apr 12, 2014

Copy link
Copy Markdown
Member

I'll try out #1563 and see if it works for my case.
But explicit is better than implicit, so I would prefer a doctests_skipfiles option.

@cdeil

cdeil commented Apr 12, 2014

Copy link
Copy Markdown
Member

I tried #1563 and it reduces the number of errors I get in gammapy/gammapy#101 .

One remaining issue is e.g. the docs/image/colormap_example.py is still run and hangs with an open matplotlib window I have to close manually.

I want the doctest runner to skip this file, but I don't want it to skip the other files in docs/image.

@embray embray added the docs label Apr 23, 2014
@embray

embray commented Apr 23, 2014

Copy link
Copy Markdown
Member

I think this is good to merge? Even if there are still issues surrounding doctests this PR is only to add a snippet to the docs, so I don't think there's much more to be done.

@cdeil

cdeil commented Apr 23, 2014

Copy link
Copy Markdown
Member

@embray This doesn't address what I need, but I can file a new issue if you want to merge this now.

embray added a commit that referenced this pull request Apr 23, 2014
Include an example of how to skip all doctests in a module
@embray
embray merged commit 8065866 into astropy:master Apr 23, 2014
embray added a commit that referenced this pull request Apr 29, 2014
Include an example of how to skip all doctests in a module
@mdboom
mdboom deleted the tests/how-to-skip-all-doctests branch May 21, 2014 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants