Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Commit f31692f

Browse files
committed
Make 'pytest -D' runs compatible with recent versions of pytest
1 parent 01f3b1e commit f31692f

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

pypy/conftest.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ def braindead_deindent(self):
3838
def pytest_report_header():
3939
return "pytest-%s from %s" % (pytest.__version__, pytest.__file__)
4040

41-
def pytest_addhooks(pluginmanager):
42-
from rpython.conftest import LeakFinder
43-
pluginmanager.register(LeakFinder())
44-
4541
def pytest_configure(config):
4642
global option
4743
option = config.option
48-
if config.getoption('direct_apptest') or not config.getoption('runappdirect'):
44+
mode_A = config.getoption('runappdirect')
45+
mode_D = config.getoption('direct_apptest')
46+
if mode_D or not mode_A:
4947
config.addinivalue_line('python_files', APPLEVEL_FN)
48+
if not mode_A and not mode_D: # 'own' tests
49+
from rpython.conftest import LeakFinder
50+
config.pluginmanager.register(LeakFinder())
51+
config.addinivalue_line('addopts', '--assert=reinterp')
5052

5153
def pytest_addoption(parser):
5254
group = parser.getgroup("pypy options")
@@ -109,7 +111,7 @@ def is_applevel(item):
109111
return isinstance(item, AppTestFunction)
110112

111113
def pytest_collection_modifyitems(config, items):
112-
if config.option.runappdirect:
114+
if config.getoption('runappdirect') or config.getoption('direct_apptest'):
113115
return
114116
for item in items:
115117
if isinstance(item, py.test.Function):

pypy/module/cpyext/test/conftest.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import pytest
33

44
def pytest_configure(config):
5-
if config.option.runappdirect:
5+
if config.getoption('runappdirect') or config.getoption('direct_apptest'):
66
import sys
77
import py
88
from pypy import pypydir
@@ -20,7 +20,8 @@ def pytest_configure(config):
2020
import pypy.module.cpyext.test.test_cpyext
2121

2222

23-
def pytest_funcarg__api(request):
23+
@pytest.fixture
24+
def api(request):
2425
return request.cls.api
2526

2627
if os.name == 'nt':

pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[pytest]
2-
addopts = --assert=reinterp -rf
2+
addopts = -rf

0 commit comments

Comments
 (0)