Skip to content

Commit 3d37b12

Browse files
committed
tests: simplify to info
1 parent 60315b2 commit 3d37b12

20 files changed

+96
-1081
lines changed

tests/conftest.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import contextlib
99
import difflib
1010
import gc
11-
import platform
1211
import re
13-
import sys
1412
import textwrap
1513

1614
import pytest
@@ -193,44 +191,3 @@ def gc_collect():
193191
def pytest_configure():
194192
pytest.suppress = suppress
195193
pytest.gc_collect = gc_collect
196-
197-
198-
# Platform Markers
199-
200-
PLAT = sys.platform.lower() # linux, osx, or win32
201-
IMPL = platform.python_implementation().lower() # cpython or pypy
202-
203-
204-
def pytest_collection_modifyitems(items):
205-
"""
206-
This will find the markers listed in pytest.ini and add
207-
skip or xfail as needed. The second part can be a platform
208-
marker (linux, osx, or win32), or python, cpython, or pypy.
209-
210-
You can add also add Python version numbers - either 2 or 3.
211-
212-
Keyword arguments are passed on.
213-
214-
# Will skip on Python 2
215-
pytest.mark.skip_python(2)
216-
217-
# Will xfail on pypy as long as TypeError is raised
218-
pytest.mark.xfail_pypy(reason="Not supported", raises=TypeError)
219-
"""
220-
for item in items:
221-
for mark in tuple(item.iter_markers()):
222-
# Check for recognised name
223-
parts = mark.name.split("_")
224-
if len(parts) == 2 and parts[0] in {"xfail", "skip"}:
225-
marker = getattr(pytest.mark, parts[0])
226-
227-
if parts[1] in {PLAT, IMPL, "python"}:
228-
# args lets you remove only Py 2 or 3
229-
if mark.args:
230-
(ver,) = mark.args # Only single argument supported
231-
assert isinstance(ver, int), "should be a version number"
232-
if ver == sys.version_info.major:
233-
item.add_marker(marker(**mark.kwargs))
234-
else:
235-
assert parts[1] != "python", "version required (otherwise use mark.skip)"
236-
item.add_marker(marker(**mark.kwargs))

tests/info.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
import platform
3+
import sys
4+
5+
LINUX = sys.platform.startswith("linux")
6+
MACOS = sys.platform.startswith("darwin")
7+
WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin")
8+
9+
CPYTHON = platform.python_implementation() == "CPython"
10+
PYPY = platform.python_implementation() == "PyPy"
11+
12+
PY2 = sys.version_info.major == 2

tests/pytest.ini

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
[pytest]
2-
minversion = 3.0
2+
minversion = 3.6
33
norecursedirs = test_cmake_build test_embed
44
addopts =
55
# show summary of skipped tests
66
-rs
7-
# Report xfails (uncomment to use
7+
# Report xfails (uncomment to use)
88
# -rx
99
# capture only Python print and C++ py::print, but not C output (low-level Python errors)
1010
--capture=sys
1111
# warnings for deprecated features
1212
-Wd
13-
# Error if markers are not listed below as well
14-
# Requires pytest 4.5, so not added here
15-
# --strict-markers
1613
xfail_strict = true
1714
filterwarnings =
1815
# make warnings into errors but ignore certain third-party extension issues
@@ -22,16 +19,3 @@ filterwarnings =
2219
# bogus numpy ABI warning (see numpy/#432)
2320
ignore:.*numpy.dtype size changed.*:RuntimeWarning
2421
ignore:.*numpy.ufunc size changed.*:RuntimeWarning
25-
markers =
26-
xfail_linux: expected failure on Linux
27-
xfail_darwin: expected failure on MacOS
28-
xfail_win32: expected failure on Windows
29-
xfail_python: expected failure on Python (2 or 3 required)
30-
xfail_cpython: expected failure on CPython
31-
xfail_pypy: not valid on PyPy (2+3)
32-
skip_linux: not valid on Linux
33-
skip_darwin: not valid on MacOS
34-
skip_win32: not valid on Windows
35-
skip_python: not valid on Python (2 or 3 required)
36-
skip_cpython: not valid on CPython
37-
skip_pypy: not valid on PyPy (2+3)

0 commit comments

Comments
 (0)