Skip to content

Commit

Permalink
TST: avoid making pytest a hard dependency to unyt.dask_array
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Jan 17, 2023
1 parent 44a0a27 commit a39dd45
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions unyt/dask_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@
"""

import sys
from functools import wraps

import numpy as np
import pytest

import unyt.array as ua

pytest.importorskip("dask")
del pytest
if "pytest" in sys.modules:
# should only happen if pytest is installed *and* already imported,
# so we can skip collecting doctests from this module when dask isn't installed
# while avoiding making pytest itself a hard dependency to this module.
# This check is constructed to work with direct invocation (pytest unyt)
# as well as through python -m pytest
import pytest

pytest.importorskip("dask")
del pytest

from dask.array.core import Array as DaskArray, finalize as dask_finalize # noqa: E402

# the following attributes hang off of dask.array.core.Array and do not modify units
Expand Down

0 comments on commit a39dd45

Please sign in to comment.