astropy / pytest-remotedata

Pytest plugin to control whether tests are run that have remote data
BSD 3-Clause "New" or "Revised" License
23 stars 15 forks source link

Remotedata rst handler #5

Closed MSeifert04 closed 7 years ago

MSeifert04 commented 7 years ago

Not sure if this would be a good fit for this package but is it possible to make a code-block-like skip-remote directive that would work like the decorator for the pytest functions, i.e. only runs the doctest if --remote-data has been specified?

astrofrog commented 7 years ago

I might be misunderstanding, but does this not already exist?

http://docs.astropy.org/en/stable/development/testguide.html?highlight=REMOTE_DATA#working-with-data-files

specifically:

>>> datafile = get_data_filename('hash/94935')  # doctest: +REMOTE_DATA

this works in docstrings and in rst files.

MSeifert04 commented 7 years ago

Ah, I haven't seen that one. I was actually thinking of something like this:

.. skip-no_remote::
   >>> code that does something with remote-data
   >>> more code that relies on the remote-data access earlier.

But +REMOTE_DATA would also work, it's just more verbose.

bsipocz commented 7 years ago

afaik we don't yet have a directive that would work for a block of doctest, either for remote-data or for float_cmp, they would be nice to have additions though.

Here are the related issues: https://github.com/astropy/astropy/issues/2662 and https://github.com/astropy/astropy/issues/2830

astrofrog commented 7 years ago

Ah yes that would be cool!

drdavella commented 7 years ago

I think these probably actually belong in https://github.com/astropy/pytest-doctestplus, although any directive dealing with remote data will introduce a dependency on this plugin.

bsipocz commented 7 years ago

all of these will be part of pytest-astropy, so cross dependency shouldn't be a problem I think.

drdavella commented 7 years ago

@bsipocz while that is true, the main motivation for breaking these into separate plugins packages is to make them available to packages a la carte, right? In any case it shouldn't be a big deal because it can just be an optional dependency.

My main point is that anything that defines a new doctest directive doesn't belong here: it belongs in pytest-doctestplus.

astrofrog commented 7 years ago

I agree that this belongs in doctestplus, with a dependency on this package

MSeifert04 commented 7 years ago

will you open an issue there or should I?

drdavella commented 7 years ago

I created two new issues there and will close this one: https://github.com/astropy/pytest-doctestplus/issues/2 https://github.com/astropy/pytest-doctestplus/issues/3

MSeifert04 commented 7 years ago

Thanks @drdavella