-
Notifications
You must be signed in to change notification settings - Fork 742
Expand file tree
/
Copy pathmarks.py
More file actions
71 lines (59 loc) · 1.91 KB
/
marks.py
File metadata and controls
71 lines (59 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from __future__ import annotations
from enum import Enum, auto
from importlib.util import find_spec
import pytest
class QuietMarkDecorator(pytest.MarkDecorator):
def __init__(self, mark: pytest.Mark) -> None:
super().__init__(mark, _ispytest=True)
class needs(QuietMarkDecorator, Enum): # noqa: N801
"""Pytest skip marker evaluated at module import.
This allows us to see the amount of skipped tests at the start of a test run.
:func:`pytest.importorskip` skips tests after they started running.
"""
# _generate_next_value_ needs to come before members
@staticmethod
def _generate_next_value_(
name: str, start: int, count: int, last_values: list[str]
) -> str:
"""Distribution name for matching modules."""
return name.replace("_", "-")
mod: str
colour = "colour-science"
dask = auto()
dask_ml = auto()
fa2 = auto()
gprofiler = "gprofiler-official"
leidenalg = auto()
louvain = auto()
openpyxl = auto()
igraph = auto()
pybiomart = auto()
skimage = "scikit-image"
skmisc = "scikit-misc"
zarr = auto()
# external
bbknn = auto()
harmony = "harmonyTS"
harmonypy = auto()
magic = "magic-impute"
palantir = auto()
phate = auto()
phenograph = auto()
pypairs = auto()
samalg = "sam-algorithm"
scanorama = auto()
trimap = auto()
wishbone = "wishbone-dev"
def __init__(self, mod: str) -> None:
self.mod = mod
reason = self.skip_reason
dec = pytest.mark.skipif(bool(reason), reason=reason or "")
super().__init__(dec.mark)
@property
def skip_reason(self) -> str | None:
if find_spec(self._name_):
return None
reason = f"needs module `{self._name_}`"
if self._name_.casefold() != self.mod.casefold().replace("-", "_"):
reason = f"{reason} (`pip install {self.mod}`)"
return reason