From: Michael Orlitzky Date: Sat, 15 May 2010 19:25:39 +0000 (-0400) Subject: Separate the tests that hit the database from the rest of the tests. X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fcensus-tools.git;a=commitdiff_plain;h=856b96616bcfcbc6f5c9e04b6f6dcc07fa7a1ff7 Separate the tests that hit the database from the rest of the tests. --- diff --git a/bin/run_tests b/bin/run_tests index 3a73264..4ce94e7 100755 --- a/bin/run_tests +++ b/bin/run_tests @@ -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 diff --git a/src/Tests/Unit/CensusTest.py b/src/Tests/Unit/CensusTest.py index 0789e2f..531d4dd 100644 --- a/src/Tests/Unit/CensusTest.py +++ b/src/Tests/Unit/CensusTest.py @@ -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