]> git.phdru.name Git - m_librarian.git/blobdiff - tests/dbutils.py
CI: Run tests at Travis and AppVeyor
[m_librarian.git] / tests / dbutils.py
index c315fff5e4914ecc2ece30d59b81d3de1301c2d2..bb5a362a18e0b576065b76bfd80c3a247945b64e 100644 (file)
@@ -1,5 +1,6 @@
 
 import os
+from sqlobject.tests.dbtest import getConnection
 from m_librarian.db import open_db, init_db
 from m_librarian.inp import import_inpx
 
@@ -7,19 +8,23 @@ __all__ = ['setup_module', 'teardown_module', 'load_inpx']
 
 
 def setup_module():
-    try:
-        os.remove('/tmp/m_librarian-test.sqlite')
-    except OSError:
-        pass
-    open_db('sqlite:///tmp/m_librarian-test.sqlite')
+    connection = getConnection()
+    if connection.dbName == 'sqlite':
+        try:
+            connection.dropDatabase()
+        except OSError:
+            pass
+    open_db(connection.uri())
     init_db()
 
 
 def teardown_module():
-    try:
-        os.remove('/tmp/m_librarian-test.sqlite')
-    except OSError:
-        pass
+    connection = getConnection()
+    if connection.dbName == 'sqlite':
+        try:
+            connection.dropDatabase()
+        except OSError:
+            pass
 
 
 def load_inpx(inpx):