Author: phd
Date: Sun Aug 11 11:06:04 2013
New Revision: 4628
Log:
A number of fixes for tests inspired by Neil Muller
sqlobject/tests/test_basic.py - add a cleanup to test_connection_override;
without this, the tests in versioning will fail if they are run after
test_basic.
sqlobject/tests/test_sqlobject_admin.py - do not create a special connection,
use whatever is provided by test system.
sqlobject/tests/test_transactions.py - skip some transaction tests if the
sqlite memory database is being used, since they will fail in this case because
of how the memory database connections are shared.
sqlobject/inheritance/tests/test_asdict.py - avoid a problem with both
inheritance/tests/test_asdict.py and inheritance/tests/test_inheritance.py
using the same classes, which cases problems when running all the tests
together; rename the classes.
Modified:
SQLObject/branches/1.5/sqlobject/inheritance/tests/test_asdict.py
SQLObject/branches/1.5/sqlobject/tests/test_basic.py
SQLObject/branches/1.5/sqlobject/tests/test_sqlobject_admin.py
SQLObject/branches/1.5/sqlobject/tests/test_transactions.py
Modified: SQLObject/branches/1.5/sqlobject/inheritance/tests/test_asdict.py
==============================================================================
--- SQLObject/branches/1.5/sqlobject/inheritance/tests/test_asdict.py Fri Jul 26 04:16:35 2013 (r4627)
+++ SQLObject/branches/1.5/sqlobject/inheritance/tests/test_asdict.py Sun Aug 11 11:06:04 2013 (r4628)
@@ -6,37 +6,37 @@
## sqlmeta.asDict
########################################
-class InheritablePerson(InheritableSQLObject):
- first = StringCol()
- last = StringCol(alternateID=True, length=255)
+class InheritablePersonAD(InheritableSQLObject):
+ firstName = StringCol()
+ lastName = StringCol(alternateID=True, length=255)
-class Boss(InheritablePerson):
+class ManagerAD(InheritablePersonAD):
department = StringCol()
-class Employee(InheritablePerson):
+class Employee(InheritablePersonAD):
_inheritable = False
position = StringCol()
def test_getColumns():
- setupClass([InheritablePerson, Boss, Employee])
+ setupClass([InheritablePersonAD, ManagerAD, Employee])
for klass, columns in (
- (InheritablePerson, ['first', 'last']),
- (Boss, ['department', 'first', 'last']),
- (Employee, ['first', 'last', 'position'])):
+ (InheritablePersonAD, ['firstName', 'lastName']),
+ (ManagerAD, ['department', 'firstName', 'lastName']),
+ (Employee, ['firstName', 'lastName', 'position'])):
_columns = klass.sqlmeta.getColumns().keys()
_columns.sort()
assert _columns == columns
def test_asDict():
- setupClass([InheritablePerson, Boss, Employee])
- InheritablePerson(first='Oneof', last='Authors')
- Boss(first='Boss', last='The', department='Dep')
- Employee(first='Project', last='Leader', position='Project leader')
-
- assert InheritablePerson.get(1).sqlmeta.asDict() == \
- dict(first='Oneof', last='Authors', id=1)
- assert InheritablePerson.get(2).sqlmeta.asDict() == \
- dict(first='Boss', last='The', department='Dep', id=2)
- assert InheritablePerson.get(3).sqlmeta.asDict() == \
- dict(first='Project', last='Leader', position='Project leader', id=3)
+ setupClass([InheritablePersonAD, ManagerAD, Employee])
+ InheritablePersonAD(firstName='Oneof', lastName='Authors')
+ ManagerAD(firstName='ManagerAD', lastName='The', department='Dep')
+ Employee(firstName='Project', lastName='Leader', position='Project leader')
+
+ assert InheritablePersonAD.get(1).sqlmeta.asDict() == \
+ dict(firstName='Oneof', lastName='Authors', id=1)
+ assert InheritablePersonAD.get(2).sqlmeta.asDict() == \
+ dict(firstName='ManagerAD', lastName='The', department='Dep', id=2)
+ assert InheritablePersonAD.get(3).sqlmeta.asDict() == \
+ dict(firstName='Project', lastName='Leader', position='Project leader', id=3)
Modified: SQLObject/branches/1.5/sqlobject/tests/test_basic.py
==============================================================================
--- SQLObject/branches/1.5/sqlobject/tests/test_basic.py Fri Jul 26 04:16:35 2013 (r4627)
+++ SQLObject/branches/1.5/sqlobject/tests/test_basic.py Sun Aug 11 11:06:04 2013 (r4628)
@@ -305,3 +305,4 @@
class TestSO13(SQLObject):
_connection = connectionForURI('sqlite:///db2')
assert TestSO13._connection.uri() == 'sqlite:///db2'
+ del sqlhub.processConnection
Modified: SQLObject/branches/1.5/sqlobject/tests/test_sqlobject_admin.py
==============================================================================
--- SQLObject/branches/1.5/sqlobject/tests/test_sqlobject_admin.py Fri Jul 26 04:16:35 2013 (r4627)
+++ SQLObject/branches/1.5/sqlobject/tests/test_sqlobject_admin.py Sun Aug 11 11:06:04 2013 (r4628)
@@ -4,8 +4,6 @@
from sqlobject import *
-sqlhub.processConnection = connectionForURI('postgres://pgsql@/db_test')
-
class Test1(SQLObject):
class sqlmeta:
createSQL = "CREATE SEQUENCE db_test1_seq;"
Modified: SQLObject/branches/1.5/sqlobject/tests/test_transactions.py
==============================================================================
--- SQLObject/branches/1.5/sqlobject/tests/test_transactions.py Fri Jul 26 04:16:35 2013 (r4627)
+++ SQLObject/branches/1.5/sqlobject/tests/test_transactions.py Sun Aug 11 11:06:04 2013 (r4628)
@@ -56,7 +56,10 @@
if not supports('transactions'):
return
setupClass(TestSOTrans)
- trans = TestSOTrans._connection.transaction()
+ connection = TestSOTrans._connection
+ if (connection.dbName == 'sqlite') and connection._memory:
+ return # The following test requires a different connection
+ trans = connection.transaction()
try:
TestSOTrans(name='bob')
bIn = TestSOTrans.byName('bob', connection=trans)
@@ -71,7 +74,7 @@
raises(SQLObjectNotFound, "bOutInst.name")
finally:
trans.rollback()
- TestSOTrans._connection.autoCommit = True
+ connection.autoCommit = True
def test_transaction_delete_with_close():
test_transaction_delete(close=True)
|