Permalink
Browse files

generate random task db in tests

avoids potential conflict with simultaneous test runs

per review by @fperez
  • Loading branch information...
1 parent 6035c93 commit 4d628d61cc059b42316d1a8828b4d4b707cced3b @minrk committed Apr 16, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 IPython/parallel/tests/test_db.py
@@ -38,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()
@@ -219,7 +225,8 @@ 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()
@@ -228,6 +235,6 @@ def tearDown(self):
def teardown():
"""cleanup task db file after all tests have run"""
try:
- os.remove(os.path.join(tempfile.gettempdir(), 'tasks.db'))
+ os.remove(temp_db)
except:
pass

0 comments on commit 4d628d6

Please sign in to comment.