Use unittest2's module hooks for setting up the django environment.
[htsworkflow.git] / htsworkflow / submission / test / test_condorfastq.py
index ffb9f88620356ba0e61800db60fa4715463515e2..09d68083c1ec50052c450a71e9d9e24356573cf7 100644 (file)
@@ -7,6 +7,10 @@ import shutil
 import tempfile
 
 from django.test import TestCase
+from django.test.utils import setup_test_environment, \
+     teardown_test_environment
+from django.db import connection
+from django.conf import settings
 
 from htsworkflow.submission.condorfastq import CondorFastqExtract
 from htsworkflow.submission.results import ResultMap
@@ -676,6 +680,16 @@ class TestCondorFastq(TestCase):
             self.assertTrue('12345_C02F9ACXX_c202_l3_r2.fastq' in arguments[3])
 
 
+OLD_DB = settings.DATABASES['default']['NAME']
+def setUpModule():
+    setup_test_environment()
+    connection.creation.create_test_db()
+
+def tearDownModule():
+    connection.creation.destroy_test_db(OLD_DB)
+    teardown_test_environment()
+
+
 def suite():
     from unittest2 import TestSuite, defaultTestLoader
     suite = TestSuite()