Commits

Ronny Pfannschmidt committed 812974e

work around pytest issue 251

collection ignores test classes with __init__ for unittest support, but is silent about that

Comments (0)

Files changed (1)

rpython/conftest.py

 import py, pytest
 from rpython.tool import leakfinder
 
-# XXX
-# <ronny> Aquana, i just ensured that with the pypy conftest we get all skips,
-# i'll investigate differences in collection tommorow, for now, can you just
-# import the makemodule hook from pypy and add a comment that im responsible
-# for fixing?
-from pypy.conftest import pytest_pycollect_makemodule
-
 cdir = realpath(join(dirname(__file__), 'translator', 'c'))
 cache_dir = realpath(join(dirname(__file__), '_cache'))
 option = None
     set_platform(value, None)
 
 def pytest_addoption(parser):
-    # XXX
-    # <ronny> Aquana, i just ensured that with the pypy conftest we get all skips,
-    # i'll investigate differences in collection tommorow, for now, can you just
-    # import the makemodule hook from pypy and add a comment that im responsible
-    # for fixing?
-    from pypy.conftest import pytest_addoption
-    pytest_addoption(parser)
-    
-    
     group = parser.getgroup("rpython options")
     group.addoption('--view', action="store_true", dest="view", default=False,
            help="view translation tests' flow graphs with Pygame")
            default=False, dest="viewloops",
            help="show only the compiled loops")
 
+
+def pytest_pycollect_makeitem(__multicall__,collector, name, obj):
+    res = __multicall__.execute()
+    # work around pytest issue 251
+    import inspect
+    if res is None and inspect.isclass(obj) and \
+            collector.classnamefilter(name):
+        return py.test.collect.Class(name, parent=collector)
+    return res
+
+
 def pytest_addhooks(pluginmanager):
     pluginmanager.register(LeakFinder())