The attached patch reworks SQLObject's test suite to be runnable with pytest 2.

With this patch, I get identical results running the test suite with
pytest 1.3.4 and pytest 2.0.3 against sqlite using python 2.7, and I
can also run the test suite against pypy, although there are several
failures on the pypy run that I still need to investigate.

-- 
Neil Muller
drnlmul...@gmail.com

I've got a gmail account. Why haven't I become cool?
Index: conftest.py
===================================================================
--- conftest.py	(revision 4418)
+++ conftest.py	(working copy)
@@ -31,28 +31,33 @@
     'mssql': 'mssql://sa:@127.0.0.1/test'
     }
 
-Option = py.test.config.Option
-option = py.test.config.addoptions(
-    "SQLObject options",
-    Option('-D', '--Database',
+def pytest_addoption(parser):
+    """Add the SQLObject options"""
+    parser.addoption('-D', '--Database',
            action="store", dest="Database", default='sqlite',
            help="The database to run the tests under (default sqlite).  "
            "Can also use an alias from: %s"
-           % (', '.join(connectionShortcuts.keys()))),
-    Option('-S', '--SQL',
+           % (', '.join(connectionShortcuts.keys())))
+    parser.addoption('-S', '--SQL',
            action="store_true", dest="show_sql", default=False,
            help="Show SQL from statements (when capturing stdout the "
-           "SQL is only displayed when a test fails)"),
-    Option('-O', '--SQL-output',
+           "SQL is only displayed when a test fails)")
+    parser.addoption('-O', '--SQL-output',
            action="store_true", dest="show_sql_output", default=False,
            help="Show output from SQL statements (when capturing "
-           "stdout the output is only displayed when a test fails)"),
-    Option('-E', '--events',
+           "stdout the output is only displayed when a test fails)")
+    parser.addoption('-E', '--events',
            action="store_true", dest="debug_events", default=False,
            help="Debug events (print information about events as they are "
-           "sent)"),
-    )
+           "sent)")
 
+option = None
+
+def pytest_configure(config):
+    """Make cmdline arguments available to dbtest"""
+    global option
+    option = config.option
+
 class SQLObjectClass(py.test.collect.Class):
     def run(self):
         if (isinstance(self.obj, type)
Index: tests/test_paste.py
===================================================================
--- tests/test_paste.py	(revision 4418)
+++ tests/test_paste.py	(working copy)
@@ -1,10 +1,12 @@
 from dbtest import *
 from sqlobject import sqlhub, SQLObject, StringCol
+import py.test
 try:
     from sqlobject.wsgi_middleware import make_middleware
 except ImportError:
-    disabled = True
+    pytestmark = py.test.mark.skipif('True')
 
+
 class NameOnly(SQLObject):
     name = StringCol()
 
Index: tests/test_boundattributes.py
===================================================================
--- tests/test_boundattributes.py	(revision 4418)
+++ tests/test_boundattributes.py	(working copy)
@@ -1,7 +1,8 @@
 from sqlobject import declarative
 from sqlobject import boundattributes
+import py.test
 
-disabled = True
+pytestmark = py.test.mark.skipif('True')
 
 class TestMe(object):
 
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to