diff --git a/Ska/DBI/tests/test_dbi.py b/Ska/DBI/tests/test_dbi.py index 67bfdd5..1a5fe9a 100644 --- a/Ska/DBI/tests/test_dbi.py +++ b/Ska/DBI/tests/test_dbi.py @@ -9,6 +9,7 @@ import pytest import numpy as np import tempfile + from Ska.DBI import DBI @@ -27,6 +28,9 @@ class DBI_BaseTests(object): def setup_class(cls): + if cls.db_config['dbi'] == 'sqlite': + cls.tmpdir = tempfile.TemporaryDirectory() + cls.db_config['server'] = os.path.join(cls.tmpdir.name, 'sqlite3.db3') cls.db = DBI(**cls.db_config) def teardown_class(cls): @@ -39,6 +43,7 @@ def teardown_class(cls): cls.db.cursor.close() cls.db.conn.close() + def test_05_force_drop_table(self): try: self.db.execute('drop table ska_dbi_test_table') @@ -92,15 +97,11 @@ def test_55_drop_table(self): class TestSqliteWithNumpy(DBI_BaseTests): - fh, fn = tempfile.mkstemp(suffix='.db3') - db_config = dict(dbi='sqlite', server=fn, numpy=True) - os.unlink(fn) + db_config = dict(dbi='sqlite', numpy=True) class TestSqliteWithoutNumpy(DBI_BaseTests): - fh, fn = tempfile.mkstemp(suffix='.db3') - db_config = dict(dbi='sqlite', server=fn, numpy=False) - os.unlink(fn) + db_config = dict(dbi='sqlite', numpy=False) @pytest.mark.skipif('not HAS_SYBASE', reason='No SYBASE_OCS and/or sybpydb.so')