Debian Codegraph @

extra_tests/conftest.py

raw symbols SCIP
1 import sys
2 import pytest
3
4 def get_marker(item, name):
5 try:
6 return item.get_closest_marker(name=name)
7 except AttributeError:
8 # pytest < 3.6
9 return item.get_marker(name=name)
10
11
12 def pytest_runtest_setup(item):
13 if get_marker(item, name='pypy_only'):
14 if '__pypy__' not in sys.builtin_module_names:
15 pytest.skip('PyPy-specific test')
16
17
18 def pytest_configure(config):
19 config.addinivalue_line("markers", "pypy_only: PyPy-specific test")
20
21 # This needs to be in the top-level conftest.py, it is copied from the one
22 # in hpy_tests/_vendored See the note at
23 # https://docs.pytest.org/en/7.1.x/reference/reference.html#initialization-hooks
24 def pytest_addoption(parser):
25 parser.addoption(
26 "--compiler-v", action="store_true",
27 help="Print to stdout the commands used to invoke the compiler")
28 parser.addoption(
29 "--subprocess-v", action="store_true",
30 help="Print to stdout the stdout and stderr of Python subprocesses"
31 "executed via run_python_subprocess")
32 parser.addoption(
33 "--dump-dir",
34 help="Enables dump mode and specifies where to write generated test "
35 "sources. This will then only generate the sources and skip "
36 "evaluation of the tests.")
37
38 def pytest_collection_modifyitems(config, items):
39 skip1 = pytest.mark.skip(reason="PyPy does not warn")
40 skip2 = pytest.mark.skip(reason="PyPy does not report a traceback")
41 for item in items:
42 if item.name == "test_more_buffer_warning":
43 item.add_marker(skip1)
44 if item.name == "test_callback_exception":
45 item.add_marker(skip2)
46