Samuele Pedroni avatar Samuele Pedroni committed 3353f63

merge changes to switch to using py.lib 1.0 final, also changes to the jit related conftests

Comments (0)

Files changed (14)

dotviewer/conftest.py

 import py
 
-class ConftestPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("dotviever")
-        group.addoption('--pygame', action="store_true", 
-            dest="pygame", default=False, 
-            help="allow interactive tests using Pygame")
+def pytest_addoption(parser):
+    group = parser.addgroup("dotviever")
+    group.addoption('--pygame', action="store_true", 
+        dest="pygame", default=False, 
+        help="allow interactive tests using Pygame")
+
+option = py.test.config.option

lib-python/conftest.py

 # Interfacing/Integrating with py.test's collection process 
 #
 
-class LibPythonPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("complicance testing options") 
-        group.addoption('-T', '--timeout', action="store", type="string", 
-           default="1000", dest="timeout", 
-           help="fail a test module after the given timeout. "
-                "specify in seconds or 'NUMmp' aka Mega-Pystones")
-        group.addoption('--pypy', action="store", type="string",
-           dest="pypy",  help="use given pypy executable to run lib-python tests. "
-                              "This will run the tests directly (i.e. not through py.py)")
+def pytest_addoption(parser):
+    group = parser.addgroup("complicance testing options") 
+    group.addoption('-T', '--timeout', action="store", type="string", 
+       default="1000", dest="timeout", 
+       help="fail a test module after the given timeout. "
+            "specify in seconds or 'NUMmp' aka Mega-Pystones")
+    group.addoption('--pypy', action="store", type="string",
+       dest="pypy",  help="use given pypy executable to run lib-python tests. "
+                          "This will run the tests directly (i.e. not through py.py)")
    
-ConftestPlugin = LibPythonPlugin
 option = py.test.config.option 
 
 def gettimeout(): 
 pytest_plugins = "resultlog",
 rsyncdirs = ['.', '../lib-python', '../demo']
 rsyncignore = ['_cache']
- 
+
+# XXX workaround for a py.test bug clashing with lib/py symlink
+# do we really need the latter?
+empty_conftest = type(sys)('conftest')
+empty_conftest.__file__ = "?"
+sys.modules['pypy.lib.py.conftest'] = empty_conftest
+
 # PyPy's command line extra options (these are added 
 # to py.test's standard options) 
 #
 
 option = py.test.config.option
 
-class PyPyTestPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("pypy options")
-        group.addoption('--view', action="store_true", dest="view", default=False,
-               help="view translation tests' flow graphs with Pygame")
-        group.addoption('-A', '--runappdirect', action="store_true",
-               default=False, dest="runappdirect",
-               help="run applevel tests directly on python interpreter (not through PyPy)")
-        group.addoption('--direct', action="store_true",
-               default=False, dest="rundirect",
-               help="run pexpect tests directly")
-        group.addoption('-P', '--platform', action="callback", type="string",
-               default="host", callback=_set_platform,
-               help="set up tests to use specified platform as compile/run target")
+def pytest_addoption(parser):
+    group = parser.addgroup("pypy options")
+    group.addoption('--view', action="store_true", dest="view", default=False,
+           help="view translation tests' flow graphs with Pygame")
+    group.addoption('-A', '--runappdirect', action="store_true",
+           default=False, dest="runappdirect",
+           help="run applevel tests directly on python interpreter (not through PyPy)")
+    group.addoption('--direct', action="store_true",
+           default=False, dest="rundirect",
+           help="run pexpect tests directly")
+    group.addoption('-P', '--platform', action="callback", type="string",
+           default="host", callback=_set_platform,
+           help="set up tests to use specified platform as compile/run target")
 
-    def pytest_funcarg__space(self, pyfuncitem):
-        return gettestobjspace()
-        
-ConftestPlugin = PyPyTestPlugin
+def pytest_funcarg__space(request):
+    return gettestobjspace()
 
 _SPACECACHE={}
 def gettestobjspace(name=None, **kwds):
                 raise AppError, AppError(appexcinfo), tb
             raise
 
-    def repr_failure(self, excinfo, outerr):
+    def repr_failure(self, excinfo):
         if excinfo.errisinstance(AppError):
             excinfo = excinfo.value.excinfo
-        return super(PyPyTestFunction, self).repr_failure(excinfo, outerr)
+        return super(PyPyTestFunction, self).repr_failure(excinfo)
 
 _pygame_imported = False
 

pypy/doc/conftest.py

 
 pytest_plugins = "pytest_restdoc"
 
-class PyPyDocPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("pypy-doc options")
-        group.addoption('--pypy-doctests', action="store_true",
-               dest="pypy_doctests", default=False, 
-               help="enable doctests in .txt files")
-        group.addoption('--generate-redirections',
-            action="store_true", dest="generateredirections",
-            default=True, help="Generate redirecting HTML files")
+def pytest_addoption(parser):
+    group = parser.addgroup("pypy-doc options")
+    group.addoption('--pypy-doctests', action="store_true",
+           dest="pypy_doctests", default=False, 
+           help="enable doctests in .txt files")
+    group.addoption('--generate-redirections',
+        action="store_true", dest="generateredirections",
+        default=True, help="Generate redirecting HTML files")
 
-    def pytest_configure(self, config):
-        self.config = config 
-        register_config_role(docdir)
-    
-    def pytest_doctest_prepare_content(self, content):
-        if not self.config.getvalue("pypy_doctests"):
-            py.test.skip("specify --pypy-doctests to run doctests")
-        l = []
-        for line in content.split("\n"):
-            if line.find('>>>>') != -1: 
-                line = "" 
-            l.append(line) 
-        return "\n".join(l) 
+def pytest_configure(config):
+    register_config_role(docdir)
 
-ConftestPlugin = PyPyDocPlugin
+def pytest_doctest_prepare_content(content):
+    if not py.test.config.getvalue("pypy_doctests"):
+        py.test.skip("specify --pypy-doctests to run doctests")
+    l = []
+    for line in content.split("\n"):
+        if line.find('>>>>') != -1: 
+            line = "" 
+        l.append(line) 
+    return "\n".join(l) 
+

pypy/jit/backend/test/conftest.py

 
 option = py.test.config.option
 
-class RandomRunnerPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup('random test options')
-        group.addoption('--random-seed', action="store", type="int",
-                        default=random.randrange(0, 10000),
-                        dest="randomseed",
-                        help="choose a fixed random seed")
-        group.addoption('--backend', action="store",
-                        default='llgraph',
-                        choices=['llgraph', 'minimal', 'x86'],
-                        dest="backend",
-                        help="select the backend to run the functions with")
-        group.addoption('--block-length', action="store", type="int",
-                        default=30,
-                        dest="block_length",
-                        help="insert up to this many operations in each test")
-        group.addoption('--n-vars', action="store", type="int",
-                        default=10,
-                        dest="n_vars",
-                        help="supply this many randomly-valued arguments to "
-                             "the function")
-        group.addoption('--repeat', action="store", type="int",
-                        default=15,
-                        dest="repeat",
-                        help="run the test this many times"),
-        group.addoption('--output', '-O', action="store", type="str",
-                        default="", dest="output",
-                        help="dump output to a file")
+def pytest_addoption(parser):
+    group = parser.addgroup('random test options')
+    group.addoption('--random-seed', action="store", type="int",
+                    default=random.randrange(0, 10000),
+                    dest="randomseed",
+                    help="choose a fixed random seed")
+    group.addoption('--backend', action="store",
+                    default='llgraph',
+                    choices=['llgraph', 'minimal', 'x86'],
+                    dest="backend",
+                    help="select the backend to run the functions with")
+    group.addoption('--block-length', action="store", type="int",
+                    default=30,
+                    dest="block_length",
+                    help="insert up to this many operations in each test")
+    group.addoption('--n-vars', action="store", type="int",
+                    default=10,
+                    dest="n_vars",
+                    help="supply this many randomly-valued arguments to "
+                         "the function")
+    group.addoption('--repeat', action="store", type="int",
+                    default=15,
+                    dest="repeat",
+                    help="run the test this many times"),
+    group.addoption('--output', '-O', action="store", type="str",
+                    default="", dest="output",
+                    help="dump output to a file")
 
-ConftestPlugin = RandomRunnerPlugin

pypy/jit/conftest.py

 import py
 
-
 option = py.test.config.option
 
-class JitTestPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("JIT options")
-        group.addoption('--slow', action="store_true",
-               default=False, dest="run_slow_tests",
-               help="run all the compiled tests (instead of just a few)")
-        group.addoption('--viewloops', action="store_true",
-               default=False, dest="viewloops",
-               help="show only the compiled loops")
+def pytest_addoption(parser):
+    group = parser.addgroup("JIT options")
+    group.addoption('--slow', action="store_true",
+           default=False, dest="run_slow_tests",
+           help="run all the compiled tests (instead of just a few)")
+    group.addoption('--viewloops', action="store_true",
+           default=False, dest="viewloops",
+           help="show only the compiled loops")
 
-
-ConftestPlugin = JitTestPlugin

pypy/jit/tl/conftest.py

-class ConftestPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("pypyjit.py options")
-        group.addoption('--ootype', action="store_true", dest="ootype", default=False,
-                help="use ootype")
+def pytest_addoption(parser):
+    group = parser.addgroup("pypyjit.py options")
+    group.addoption('--ootype', action="store_true", dest="ootype",
+                    default=False,
+                    help="use ootype")

pypy/lang/js/test/ecma/conftest.py

 rootdir = py.magic.autopath().dirpath()
 exclusionlist = ['shell.js', 'browser.js']
 
-class EcmatestPlugin:
-    def pytest_addoption(self, parser):
-        parser.addoption('--ecma',
-               action="store_true", dest="ecma", default=False,
-               help="run js interpreter ecma tests"
-        )
+def pytest_addoption(parser):
+    parser.addoption('--ecma',
+           action="store_true", dest="ecma", default=False,
+           help="run js interpreter ecma tests"
+    )
 
-    def pytest_collect_file(self, path, parent):
-        if path.ext == ".js" and path.basename not in exclusionlist:
-            if not parent.config.option.ecma:
-                py.test.skip("ECMA tests disabled, run with --ecma")
-            return JSTestFile(path, parent=parent)
-
-ConftestPlugin = EcmatestPlugin
+def pytest_collect_file(path, parent):
+    if path.ext == ".js" and path.basename not in exclusionlist:
+        if not parent.config.option.ecma:
+            py.test.skip("ECMA tests disabled, run with --ecma")
+        return JSTestFile(path, parent=parent)
 
 class JSTestFile(py.test.collect.File):
     def init_interp(cls):

pypy/module/pypyjit/test/conftest.py

-class PyPyJitTestPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("pypyjit options")
-        group.addoption("--pypy-c", action="store", default=None, dest="pypy_c",
-                        help="the location of the JIT enabled pypy-c")
+def pytest_addoption(parser):
+    group = parser.addgroup("pypyjit options")
+    group.addoption("--pypy-c", action="store", default=None, dest="pypy_c",
+                    help="the location of the JIT enabled pypy-c")
 
-ConftestPlugin = PyPyJitTestPlugin

pypy/objspace/std/fake.py

                                        unwrap_spec=[baseobjspace.ObjSpace,
                                                     baseobjspace.W_Root,
                                                     argument.Arguments])
-    if cpy_type.__base__ is not object:
+    if cpy_type.__base__ is not object and not issubclass(cpy_type, Exception):
         assert cpy_type.__base__ is basestring, cpy_type
         from pypy.objspace.std.basestringtype import basestring_typedef
         base = basestring_typedef

pypy/tool/test/test_conftest1.py

         assert len(passed) == 2
         assert not skipped and not failed 
         for repevent in passed: 
-            assert repevent.colitem.name in ('test_something', 'test_method')
+            assert repevent.item.name in ('test_something', 'test_method')
 
     def test_select_applevel(self, testdir): 
         sorter = testdir.inline_run("-k", "applevel", innertest)
         assert len(passed) == 2
         assert not skipped and not failed 
         for repevent in passed: 
-            assert repevent.colitem.name in ('app_test_something', 'test_method_app')
+            assert repevent.item.name in ('app_test_something', 'test_method_app')
 
     def test_appdirect(self, testdir):
         sorter = testdir.inline_run(innertest, '-k', 'applevel', '--runappdirect')
         passed, skipped, failed = sorter.listoutcomes()
         assert len(passed) == 2
         print passed
-        names = [x.colitem.name for x in passed]
+        names = [x.item.name for x in passed]
         assert 'app_test_something' in names 
         assert 'test_method_app' in names 
         

pypy/tool/test/test_pytestsupport.py

     else:
         py.test.fail("did not raise!")
     assert "PicklingError" in appex.exconly()
-    assert "SomeMessage" in appex.exconly()
 
 class AppTestWithWrappedInterplevelAttributes: 
     def setup_class(cls): 
             def test_one(self):
                 pass
     """)
-    ev, = sorter.getnamed("itemtestreport")
+    ev, = sorter.getreports("pytest_runtest_logreport")
     assert ev.passed 
-    sfn = ev.colitem.safe_filename()
+    sfn = ev.item.safe_filename()
     print sfn
     assert sfn == 'test_safe_filename_test_safe_filename_ExpectTestOne_paren_test_one_1.py'
 
 
 def test_app_test_blow(testdir):
     conftestpath.copy(testdir.tmpdir)
-    sorter = testdir.inline_runsource("""
-class AppTestBlow:
-    def test_one(self):
-        exec 'blow'
+    sorter = testdir.inline_runsource("""class AppTestBlow:
+    def test_one(self): exec 'blow'
     """)
 
-    ev, = sorter.getnamed("itemtestreport")
+    ev, = sorter.getreports("pytest_runtest_logreport")
     assert ev.failed
+    assert 'NameError' in ev.longrepr.reprcrash.message
+    assert 'blow' in ev.longrepr.reprcrash.message    

pypy/translator/cli/conftest.py

-class ConftestPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("pypy-cli options")
-        group.addoption('--source', action="store_true", dest="source", default=False,
-                help="only generate IL source, don't compile")
-        group.addoption('--wd', action="store_true", dest="wd", default=False,
-                help="store temporary files in the working directory")
-        group.addoption('--stdout', action="store_true", dest="stdout", default=False,
-                help="print the generated IL code to stdout, too")
-        group.addoption('--nostop', action="store_true", dest="nostop", default=False,
-                help="don't stop on warning. The generated IL code could not compile")
-        group.addoption('--nowrap', action="store_true", dest="nowrap", default=False,
-                help="don't wrap exceptions but let them to flow out of the entry point")
-        group.addoption('--verify', action="store_true", dest="verify", default=False,
-                help="check that compiled executables are verifiable")
-        group.addoption('--norun', action='store_true', dest="norun", default=False,
-                help="don't run the compiled executable")
-        group.addoption('--trace', action='store_true', dest='trace', default=False,
-                help='Trace execution of generated code')
+def pytest_addoption(parser):
+    group = parser.addgroup("pypy-cli options")
+    group.addoption('--source', action="store_true", dest="source", default=False,
+            help="only generate IL source, don't compile")
+    group.addoption('--wd', action="store_true", dest="wd", default=False,
+            help="store temporary files in the working directory")
+    group.addoption('--stdout', action="store_true", dest="stdout", default=False,
+            help="print the generated IL code to stdout, too")
+    group.addoption('--nostop', action="store_true", dest="nostop", default=False,
+            help="don't stop on warning. The generated IL code could not compile")
+    group.addoption('--nowrap', action="store_true", dest="nowrap", default=False,
+            help="don't wrap exceptions but let them to flow out of the entry point")
+    group.addoption('--verify', action="store_true", dest="verify", default=False,
+            help="check that compiled executables are verifiable")
+    group.addoption('--norun', action='store_true', dest="norun", default=False,
+            help="don't run the compiled executable")
+    group.addoption('--trace', action='store_true', dest='trace', default=False,
+            help='Trace execution of generated code')

pypy/translator/jvm/conftest.py

-class ConftestPlugin:
-    def pytest_addoption(self, parser):
-        group = parser.addgroup("pypy-jvm options")
-        group.addoption('--java', action='store', dest='java', default='java',
-                help='Define the java executable to use')
-        group.addoption('--javac', action='store', dest='javac', default='javac',
-                help='Define the javac executable to use')
-        group.addoption('--jasmin', action='store', dest='java', default='java',
-                help='Define the jasmin script to use')
-        group.addoption('--noassemble', action='store_true', dest="noasm", default=False,
-                help="don't assemble jasmin files")
-        group.addoption('--package', action='store', dest='package', default='pypy',
-                help='Package to output generated classes into')
-##        group.addoption('--trace', action='store_true', dest='trace', default=False,
-##                help='Trace execution of generated code')
-        group.addoption('--byte-arrays', action='store_true', dest='byte-arrays',
-                default=False, help='Use byte arrays rather than native strings')
 
+def pytest_addoption(parser):
+    group = parser.addgroup("pypy-jvm options")
+    group.addoption('--java', action='store', dest='java', default='java',
+            help='Define the java executable to use')
+    group.addoption('--javac', action='store', dest='javac',
+                    default='javac',
+                    help='Define the javac executable to use')
+    group.addoption('--jasmin', action='store', dest='java', default='java',
+            help='Define the jasmin script to use')
+    group.addoption('--noassemble', action='store_true', dest="noasm",
+                    default=False,
+                    help="don't assemble jasmin files")
+    group.addoption('--package', action='store', dest='package',
+                    default='pypy',
+                    help='Package to output generated classes into')
+
+    group.addoption('--byte-arrays', action='store_true',
+                    dest='byte-arrays',
+                    default=False,
+                    help='Use byte arrays rather than native strings')
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.