Author: Ronan Lamy <[email protected]>
Branch: py3tests
Changeset: r97037:694c772c9e9f
Date: 2019-07-30 18:14 +0100
http://bitbucket.org/pypy/pypy/changeset/694c772c9e9f/

Log:    Use -D flag for new-style apptests

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -47,31 +47,39 @@
 def pytest_report_header():
     return "pytest-%s from %s" % (pytest.__version__, pytest.__file__)
 
-def pytest_addhooks(pluginmanager):
-    if sys.version_info < (3,):
-        from rpython.conftest import LeakFinder
-        pluginmanager.register(LeakFinder())
[email protected](tryfirst=True)
+def pytest_cmdline_preparse(config, args):
+    if not (set(args) & {'-D', '--direct-apptest'}):
+        args.append('--assert=reinterp')
 
 def pytest_configure(config):
-    if HOST_IS_PY3 and not config.getoption('runappdirect'):
+    if HOST_IS_PY3 and not config.getoption('direct_apptest'):
         raise ValueError(
-            "On top of a Python 3 interpreter, the -A flag is mandatory")
+            "On top of a Python 3 interpreter, the -D flag is mandatory")
     global option
     option = config.option
+    mode_A = config.getoption('runappdirect')
+    mode_D = config.getoption('direct_apptest')
     def py3k_skip(message):
         py.test.skip('[py3k] %s' % message)
     py.test.py3k_skip = py3k_skip
-    if HOST_IS_PY3 or not config.getoption('runappdirect'):
+    if mode_D or not mode_A:
         config.addinivalue_line('python_files', APPLEVEL_FN)
+    if not mode_A and not mode_D:  # 'own' tests
+        from rpython.conftest import LeakFinder
+        config.pluginmanager.register(LeakFinder())
 
 def pytest_addoption(parser):
     group = parser.getgroup("pypy options")
     group.addoption('-A', '--runappdirect', action="store_true",
            default=False, dest="runappdirect",
-           help="run applevel tests directly on the python interpreter " +
+           help="run legacy applevel tests directly on the python interpreter 
" +
                 "specified by --python")
     group.addoption('--python', type="string", default=PYTHON3,
            help="python interpreter to run appdirect tests with")
+    group.addoption('-D', '--direct-apptest', action="store_true",
+           default=False, dest="direct_apptest",
+           help="run applevel_XXX.py tests directly on host interpreter")
     group.addoption('--direct', action="store_true",
            default=False, dest="rundirect",
            help="run pexpect tests directly")
@@ -114,9 +122,9 @@
     ensure_pytest_builtin_helpers()
 
 def pytest_pycollect_makemodule(path, parent):
-    if HOST_IS_PY3:
-        return
-    elif path.fnmatch(APPLEVEL_FN):
+    if path.fnmatch(APPLEVEL_FN):
+        if parent.config.getoption('direct_apptest'):
+            return
         from pypy.tool.pytest.apptest2 import AppTestModule
         rewrite = parent.config.getoption('applevel_rewrite')
         return AppTestModule(path, parent, rewrite_asserts=rewrite)
@@ -128,7 +136,7 @@
     return isinstance(item, AppTestFunction)
 
 def pytest_collection_modifyitems(config, items):
-    if config.option.runappdirect:
+    if config.getoption('runappdirect') or config.getoption('direct_apptest'):
         return
     for item in items:
         if isinstance(item, py.test.Function):
@@ -219,8 +227,8 @@
                 appclass.obj.space = LazyObjSpaceGetter()
             appclass.obj.runappdirect = option.runappdirect
 
-
 def pytest_ignore_collect(path, config):
-    if (HOST_IS_PY3 and not path.isdir() and not path.fnmatch(APPLEVEL_FN)):
+    if (config.getoption('direct_apptest') and not path.isdir()
+            and not path.fnmatch(APPLEVEL_FN)):
         return True
     return path.check(link=1)
diff --git a/pypy/module/_continuation/test/conftest.py 
b/pypy/module/_continuation/test/conftest.py
--- a/pypy/module/_continuation/test/conftest.py
+++ b/pypy/module/_continuation/test/conftest.py
@@ -2,6 +2,7 @@
 
 def pytest_configure(config):
     if (not config.getoption('runappdirect') and
+            not config.getoption('direct_apptest') and
             sys.platform.startswith('linux')):
         from rpython.rlib.rvmprof.cintf import configure_libbacktrace_linux
         configure_libbacktrace_linux()
diff --git a/pypy/module/_cppyy/test/conftest.py 
b/pypy/module/_cppyy/test/conftest.py
--- a/pypy/module/_cppyy/test/conftest.py
+++ b/pypy/module/_cppyy/test/conftest.py
@@ -41,17 +41,14 @@
 disabled = None
 
 def pytest_configure(config):
-    if config.getoption('runappdirect'):
-        return
+    if config.getoption('runappdirect') or config.getoption('direct_apptest'):
+        return       # "can't run dummy tests in -A"
     if py.path.local.sysfind('genreflex') is None:
         import pypy.module._cppyy.capi.loadable_capi as lcapi
         try:
             import ctypes
             ctypes.CDLL(lcapi.backend_library)
         except Exception as e:
-            if config.option.runappdirect:
-                return       # "can't run dummy tests in -A"
-
             # build dummy backend (which has reflex info and calls hard-wired)
             import os
             from rpython.translator.tool.cbuild import ExternalCompilationInfo
diff --git a/pypy/module/cpyext/test/conftest.py 
b/pypy/module/cpyext/test/conftest.py
--- a/pypy/module/cpyext/test/conftest.py
+++ b/pypy/module/cpyext/test/conftest.py
@@ -2,7 +2,7 @@
 import pytest
 
 def pytest_configure(config):
-    if config.option.runappdirect:
+    if config.getoption('runappdirect') or config.getoption('direct_apptest'):
         import sys
         import py
         from pypy import pypydir
@@ -20,7 +20,8 @@
     import pypy.module.cpyext.test.test_cpyext
 
 
-def pytest_funcarg__api(request):
[email protected]
+def api(request):
     return request.cls.api
 
 if os.name == 'nt':
diff --git a/pytest.ini b/pytest.ini
--- a/pytest.ini
+++ b/pytest.ini
@@ -1,2 +1,2 @@
 [pytest]
-addopts = --assert=reinterp -rf
+addopts = -rf
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to