Skip to content

Commit

Permalink
Tests: Fix a bug with sqlite-memory
Browse files Browse the repository at this point in the history
Rollback transaction and close connection.
  • Loading branch information
phdru committed Aug 1, 2017
1 parent ade481a commit 1c8a1b8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sqlobject/tests/test_transactions.py
Expand Up @@ -50,7 +50,8 @@ def test_transaction():

def test_transaction_commit_sync():
setupClass(SOTestSOTrans)
trans = SOTestSOTrans._connection.transaction()
connection = SOTestSOTrans._connection
trans = connection.transaction()
try:
SOTestSOTrans(name='bob')
bOut = SOTestSOTrans.byName('bob')
Expand All @@ -60,14 +61,16 @@ def test_transaction_commit_sync():
trans.commit()
assert bOut.name == 'robert'
finally:
SOTestSOTrans._connection.autoCommit = True
trans.rollback()
connection.autoCommit = True
connection.close()


def test_transaction_delete(close=False):
setupClass(SOTestSOTrans)
connection = SOTestSOTrans._connection
if (connection.dbName == 'sqlite') and connection._memory:
pytest.skip("The following test requires a different connection")
pytest.skip("The test doesn't work with sqlite memory connection")
trans = connection.transaction()
try:
SOTestSOTrans(name='bob')
Expand Down

0 comments on commit 1c8a1b8

Please sign in to comment.