-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
48 lines (43 loc) · 1.87 KB
/
conftest.py
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
# Copyright (c) 2010-2024 openpyxl
import pytest
import platform
### Markers ###
def pytest_runtest_setup(item):
from openpyxl import DEFUSEDXML, LXML
if isinstance(item, pytest.Function):
try:
from PIL import Image
except ImportError:
Image = False
if item.get_closest_marker("pil_required") and Image is False:
pytest.skip("PIL must be installed")
elif item.get_closest_marker("pil_not_installed") and Image:
pytest.skip("PIL is installed")
elif item.get_closest_marker("not_py33"):
pytest.skip("Ordering is not a given in Python 3")
elif item.get_closest_marker("defusedxml_required"):
if LXML or not DEFUSEDXML:
pytest.skip("defusedxml is required to guard against these vulnerabilities")
elif item.get_closest_marker("lxml_required"):
if not LXML:
pytest.skip("LXML is required for some features such as schema validation")
elif item.get_closest_marker("lxml_buffering"):
from lxml.etree import LIBXML_VERSION
if LIBXML_VERSION < (3, 4, 0, 0):
pytest.skip("LXML >= 3.4 is required")
elif item.get_closest_marker("no_lxml"):
from openpyxl import LXML
if LXML:
pytest.skip("LXML has a different interface")
elif item.get_closest_marker("numpy_required"):
from openpyxl import NUMPY
if not NUMPY:
pytest.skip("Numpy must be installed")
elif item.get_closest_marker("pandas_required"):
try:
import pandas
except ImportError as e:
pytest.skip("Pandas must be installed")
elif item.get_closest_marker("no_pypy"):
if platform.python_implementation() == "PyPy":
pytest.skip("Skipping pypy")