From 856b96616bcfcbc6f5c9e04b6f6dcc07fa7a1ff7 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 15 May 2010 15:25:39 -0400 Subject: [PATCH] Separate the tests that hit the database from the rest of the tests. --- bin/run_tests | 11 +++++++++++ src/Tests/Unit/CensusTest.py | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) 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 -- 2.44.2