Skip to content

Commit

Permalink
Skip doctests if optional dependencies are not installed (#8258)
Browse files Browse the repository at this point in the history
  • Loading branch information
GenevieveBuckley committed Oct 21, 2021
1 parent f424669 commit 6dbf095
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 10 additions & 0 deletions conftest.py
Expand Up @@ -36,6 +36,16 @@
except ImportError:
collect_ignore.append("dask/dataframe/io/orc/arrow.py")

try:
import tiledb # noqa: F401
except ImportError:
collect_ignore.append("dask/array/tiledb_io.py")

try:
import sqlalchemy # noqa: F401
except ImportError:
collect_ignore.append("dask/dataframe/io/sql.py")


def pytest_addoption(parser):
parser.addoption("--runslow", action="store_true", help="run slow tests")
Expand Down
8 changes: 4 additions & 4 deletions dask/cache.py
Expand Up @@ -13,19 +13,19 @@ class Cache(Callback):
Examples
--------
>>> cache = Cache(1e9)
>>> cache = Cache(1e9) # doctest: +SKIP
The cache can be used locally as a context manager around ``compute`` or
``get`` calls:
>>> with cache: # doctest: +SKIP
>>> with cache: # doctest: +SKIP
... result = x.compute()
You can also register a cache globally, so that it works for all
computations:
>>> cache.register()
>>> cache.unregister()
>>> cache.register() # doctest: +SKIP
>>> cache.unregister() # doctest: +SKIP
"""

def __init__(self, cache, *args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions dask/diagnostics/profile.py
Expand Up @@ -307,8 +307,8 @@ class CacheProfiler(Callback):
example, the ``nbytes`` function found in ``cachey`` can be used to measure
the number of bytes in the cache.
>>> from cachey import nbytes
>>> with CacheProfiler(metric=nbytes) as prof:
>>> from cachey import nbytes # doctest: +SKIP
>>> with CacheProfiler(metric=nbytes) as prof: # doctest: +SKIP
... get(dsk, 'z')
22
Expand Down

0 comments on commit 6dbf095

Please sign in to comment.