Author: phd
Date: 2006-10-10 08:56:35 -0600 (Tue, 10 Oct 2006)
New Revision: 1995
Modified:
SQLObject/trunk/sqlobject/tests/dbtest.py
SQLObject/trunk/sqlobject/tests/test_select.py
SQLObject/trunk/sqlobject/tests/test_sqlite_factory.py
Log:
Moved boilerplate code to set the factory for SQLiteConnection to setSQLiteConnectionFactory().
Modified: SQLObject/trunk/sqlobject/tests/dbtest.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/dbtest.py 2006-10-10 12:06:31 UTC (rev 1994)
+++ SQLObject/trunk/sqlobject/tests/dbtest.py 2006-10-10 14:56:35 UTC (rev 1995)
@@ -104,8 +104,8 @@
# At least this module should be importable...
print >> sys.stderr, (
"Could not open database: %s" % e)
-
+
class InstalledTestDatabase(sqlobject.SQLObject):
"""
This table is set up in SQLite (always, regardless of --Database) and
@@ -216,7 +216,7 @@
def __init__(self, **kw):
for name, value in kw.items():
setattr(self, name, value)
-
+
def d(**kw):
"""
Because ``dict(**kw)`` doesn't work in Python 2.2, this is a
@@ -274,10 +274,22 @@
# To avoid name clashes:
_inserts = inserts
+def setSQLiteConnectionFactory(TableClass, factory):
+ from sqlobject.sqlite.sqliteconnection import SQLiteConnection
+ conn = TableClass._connection
+ TableClass._connection = SQLiteConnection(
+ filename=conn.filename,
+ name=conn.name, debug=conn.debug, debugOutput=conn.debugOutput,
+ cache=conn.cache, style=conn.style, autoCommit=conn.autoCommit,
+ debugThreading=conn.debugThreading, registry=conn.registry,
+ factory=factory
+ )
+ installOrClear([TableClass])
+
def deprecated_module():
sqlobject.main.warnings_level = None
sqlobject.main.exception_level = None
-
+
def setup_module(mod):
# modules with '_old' test backward compatible methods, so they
# don't get warnings or errors.
Modified: SQLObject/trunk/sqlobject/tests/test_select.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_select.py 2006-10-10 12:06:31 UTC (rev 1994)
+++ SQLObject/trunk/sqlobject/tests/test_select.py 2006-10-10 14:56:35 UTC (rev 1995)
@@ -2,7 +2,7 @@
from sqlobject import *
from sqlobject.main import SQLObjectIntegrityError
from sqlobject.tests.dbtest import *
-from sqlobject.tests.dbtest import installOrClear
+from sqlobject.tests.dbtest import setSQLiteConnectionFactory
from py.test import raises
try:
@@ -163,15 +163,7 @@
self.create_function("regexp", 2, regexp)
return MyConnection
- conn = IterTest._connection
- IterTest._connection = sqliteconnection.SQLiteConnection(
- filename=conn.filename,
- name=conn.name, debug=conn.debug, debugOutput=conn.debugOutput,
- cache=conn.cache, style=conn.style, autoCommit=conn.autoCommit,
- debugThreading=conn.debugThreading, registry=conn.registry,
- factory=SQLiteConnectionFactory
- )
- installOrClear([IterTest])
+ setSQLiteConnectionFactory(IterTest, SQLiteConnectionFactory)
IterTest(name='sqlobject')
IterTest(name='sqlbuilder')
Modified: SQLObject/trunk/sqlobject/tests/test_sqlite_factory.py
===================================================================
--- SQLObject/trunk/sqlobject/tests/test_sqlite_factory.py 2006-10-10 12:06:31 UTC (rev 1994)
+++ SQLObject/trunk/sqlobject/tests/test_sqlite_factory.py 2006-10-10 14:56:35 UTC (rev 1995)
@@ -1,6 +1,6 @@
from sqlobject import *
from sqlobject.tests.dbtest import *
-from sqlobject.tests.dbtest import installOrClear
+from sqlobject.tests.dbtest import setSQLiteConnectionFactory
class SQLiteFactoryTest(SQLObject):
name = StringCol()
@@ -20,14 +20,8 @@
factory[0] = MyConnection
return MyConnection
- conn = SQLiteFactoryTest._connection
- SQLiteFactoryTest._connection = sqliteconnection.SQLiteConnection(
- filename=conn.filename,
- name=conn.name, debug=conn.debug, debugOutput=conn.debugOutput,
- cache=conn.cache, style=conn.style, autoCommit=conn.autoCommit,
- debugThreading=conn.debugThreading, registry=conn.registry,
- factory=SQLiteConnectionFactory
- )
+ setSQLiteConnectionFactory(SQLiteFactoryTest, SQLiteConnectionFactory)
+
conn = SQLiteFactoryTest._connection.makeConnection()
assert factory[0]
assert isinstance(conn, factory[0])
@@ -48,14 +42,8 @@
return MyConnection
sqliteconnection.SQLiteConnectionFactory = SQLiteConnectionFactory
- conn = SQLiteFactoryTest._connection
- SQLiteFactoryTest._connection = sqliteconnection.SQLiteConnection(
- filename=conn.filename,
- name=conn.name, debug=conn.debug, debugOutput=conn.debugOutput,
- cache=conn.cache, style=conn.style, autoCommit=conn.autoCommit,
- debugThreading=conn.debugThreading, registry=conn.registry,
- factory="SQLiteConnectionFactory"
- )
+ setSQLiteConnectionFactory(SQLiteFactoryTest, "SQLiteConnectionFactory")
+
conn = SQLiteFactoryTest._connection.makeConnection()
assert factory[0]
assert isinstance(conn, factory[0])
@@ -89,15 +77,7 @@
return MyConnection
- conn = SQLiteFactoryTest._connection
- SQLiteFactoryTest._connection = sqliteconnection.SQLiteConnection(
- filename=conn.filename,
- name=conn.name, debug=conn.debug, debugOutput=conn.debugOutput,
- cache=conn.cache, style=conn.style, autoCommit=conn.autoCommit,
- debugThreading=conn.debugThreading, registry=conn.registry,
- factory=SQLiteConnectionFactory
- )
- installOrClear([SQLiteFactoryTest])
+ setSQLiteConnectionFactory(SQLiteFactoryTest, SQLiteConnectionFactory)
SQLiteFactoryTest(name='sqlobject')
SQLiteFactoryTest(name='sqlbuilder')
|