forked from openlp/openlp
Try deleting the file itself after telling Python to do garbage collection
This commit is contained in:
parent
402917024b
commit
d7b9e2cbe5
@ -22,15 +22,17 @@
|
|||||||
"""
|
"""
|
||||||
Package to test the openlp.core.utils.db package.
|
Package to test the openlp.core.utils.db package.
|
||||||
"""
|
"""
|
||||||
|
from tempfile import mkdtemp
|
||||||
|
from unittest import TestCase
|
||||||
|
import gc
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from unittest import TestCase
|
|
||||||
from tempfile import mkdtemp
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from openlp.core.utils.db import drop_column, drop_columns
|
from openlp.core.utils.db import drop_column, drop_columns
|
||||||
from openlp.core.lib.db import init_db, get_upgrade_op
|
from openlp.core.lib.db import init_db, get_upgrade_op
|
||||||
|
|
||||||
from tests.utils.constants import TEST_RESOURCES_PATH
|
from tests.utils.constants import TEST_RESOURCES_PATH
|
||||||
|
|
||||||
|
|
||||||
@ -42,9 +44,9 @@ class TestUtilsDBFunctions(TestCase):
|
|||||||
"""
|
"""
|
||||||
self.tmp_folder = mkdtemp()
|
self.tmp_folder = mkdtemp()
|
||||||
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
db_path = os.path.join(TEST_RESOURCES_PATH, 'songs', 'songs-1.9.7.sqlite')
|
||||||
db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite')
|
self.db_tmp_path = os.path.join(self.tmp_folder, 'songs-1.9.7.sqlite')
|
||||||
shutil.copyfile(db_path, db_tmp_path)
|
shutil.copyfile(db_path, self.db_tmp_path)
|
||||||
db_url = 'sqlite:///' + db_tmp_path
|
db_url = 'sqlite:///' + self.db_tmp_path
|
||||||
self.session, metadata = init_db(db_url)
|
self.session, metadata = init_db(db_url)
|
||||||
self.op = get_upgrade_op(self.session)
|
self.op = get_upgrade_op(self.session)
|
||||||
|
|
||||||
@ -54,7 +56,9 @@ class TestUtilsDBFunctions(TestCase):
|
|||||||
"""
|
"""
|
||||||
self.session.close()
|
self.session.close()
|
||||||
self.session = None
|
self.session = None
|
||||||
|
gc.collect()
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
os.unlink(self.db_tmp_path)
|
||||||
shutil.rmtree(self.tmp_folder)
|
shutil.rmtree(self.tmp_folder)
|
||||||
|
|
||||||
def delete_column_test(self):
|
def delete_column_test(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user