]> git.phdru.name Git - m_librarian.git/blob - tests/dbutils.py
CI: Run tests at Travis and AppVeyor
[m_librarian.git] / tests / dbutils.py
1
2 import os
3 from sqlobject.tests.dbtest import getConnection
4 from m_librarian.db import open_db, init_db
5 from m_librarian.inp import import_inpx
6
7 __all__ = ['setup_module', 'teardown_module', 'load_inpx']
8
9
10 def setup_module():
11     connection = getConnection()
12     if connection.dbName == 'sqlite':
13         try:
14             connection.dropDatabase()
15         except OSError:
16             pass
17     open_db(connection.uri())
18     init_db()
19
20
21 def teardown_module():
22     connection = getConnection()
23     if connection.dbName == 'sqlite':
24         try:
25             connection.dropDatabase()
26         except OSError:
27             pass
28
29
30 def load_inpx(inpx):
31     import_inpx(os.path.join(os.path.dirname(__file__), inpx))