Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1607 from minrk/cleanup_sqlitedb

cleanup sqlitedb temporary db file after tests, and make the temp db file have a random name to avoid possible collisions with simultaneous test runs.
  • Loading branch information...
commit f57191aa67bb8d7b605a3f73d64208ff12f21743 2 parents 5750e2d + 4d628d6
@fperez fperez authored
Showing with 17 additions and 1 deletion.
  1. +17 −1 IPython/parallel/tests/test_db.py
View
18 IPython/parallel/tests/test_db.py
@@ -18,6 +18,7 @@
from __future__ import division
+import os
import tempfile
import time
@@ -37,6 +38,12 @@
# TestCases
#-------------------------------------------------------------------------------
+
+def setup():
+ global temp_db
+ temp_db = tempfile.NamedTemporaryFile(suffix='.db').name
+
+
class TestDictBackend(TestCase):
def setUp(self):
self.session = Session()
@@ -218,7 +225,16 @@ class TestSQLiteBackend(TestDictBackend):
@dec.skip_without('sqlite3')
def create_db(self):
- return SQLiteDB(location=tempfile.gettempdir())
+ location, fname = os.path.split(temp_db)
+ return SQLiteDB(location=location, fname=fname)
def tearDown(self):
self.db._db.close()
+
+
+def teardown():
+ """cleanup task db file after all tests have run"""
+ try:
+ os.remove(temp_db)
+ except:
+ pass
Please sign in to comment.
Something went wrong with that request. Please try again.