From 752e36465bfe4d712db5a8914883bcf5194f6ef1 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Wed, 4 Mar 2020 06:42:38 -0500 Subject: [PATCH] Fix / improve tests to run on Windows --- Ska/DBI/tests/test_dbi.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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')