]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Separate the tests that hit the database from the rest of the tests.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 15 May 2010 19:25:39 +0000 (15:25 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 15 May 2010 19:25:39 +0000 (15:25 -0400)
bin/run_tests
src/Tests/Unit/CensusTest.py

index 3a73264320e073acf430820a3539f31313e2307b..4ce94e771237ce22dfc15be61bf30cb5c9643cb0 100755 (executable)
@@ -5,6 +5,7 @@ import sys, os, site
 site.addsitedir(os.path.dirname(os.path.abspath(sys.argv[0])) + '/../src')
 
 import unittest
+import Census
 from Tests.Unit import CensusTest
 from Tests.Unit import DistributionTest
 from Tests.Unit import FileUtilsTest
@@ -26,3 +27,13 @@ suite.addTest(LEHDTest.suite())
 suite.addTest(UniformDistributionTest.suite())
 suite.addTest(DistributionTest.suite())
 unittest.TextTestRunner(verbosity=2).run(suite)
+
+try:
+    # The Census.Database initialization will raise an exception
+    # if the database cannot be accessed.
+    cdb = Census.Database()
+    db_suite = unittest.TestSuite()
+    db_suite.addTest(CensusTest.db_suite())
+    unittest.TextTestRunner(verbosity=2).run(db_suite)
+except:
+    pass
index 0789e2fe6b897357f359399aeb5cff2f32402f71..531d4dd0a615a2d7d27afbee8f0e36c5ebbe2cf1 100644 (file)
@@ -32,7 +32,13 @@ class DatabaseTest(unittest.TestCase):
             
     
 def suite():
+    # Tests that don't hit the database.
     suite = unittest.TestSuite()
-    suite.addTest(unittest.makeSuite(DatabaseTest))
     return suite
-        
+
+
+def db_suite():
+    # The tests that hit the database.
+    db_suite = unittest.TestSuite()
+    db_suite.addTest(unittest.makeSuite(DatabaseTest))
+    return db_suite