Skip to content

Commit

Permalink
generate random task db in tests
Browse files Browse the repository at this point in the history
avoids potential conflict with simultaneous test runs

per review by @fperez
  • Loading branch information
minrk committed Apr 16, 2012
1 parent 6035c93 commit 4d628d6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions IPython/parallel/tests/test_db.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand All @@ -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.