From: Michael Orlitzky Date: Sat, 3 Oct 2009 20:51:26 +0000 (-0400) Subject: Moved the default initialization for the Census class in to its constructor. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=0139658183fcfe4d53b7f6c2051955c8da5d05d1;p=dead%2Fcensus-tools.git Moved the default initialization for the Census class in to its constructor. Removed an unnecessary GPS import from CensusTest. --- diff --git a/src/Census.py b/src/Census.py index da9283d..63f69aa 100644 --- a/src/Census.py +++ b/src/Census.py @@ -1,5 +1,6 @@ import pgdb +import Configuration.Defaults import GPS import SummaryFile1 @@ -11,11 +12,16 @@ class Database: one or two methods from within this class. """ - def __init__(self, _host, _database, _username, _srid): - self.connection = pgdb.connect(host=_host, - database=_database, - user=_username) - self.srid = _srid + def __init__(self, + initial_host=Configuration.Defaults.DATABASE_HOST, + initial_database=Configuration.Defaults.DATABASE_NAME, + initial_username=Configuration.Defaults.DATABASE_USERNAME, + initial_srid=Configuration.Defaults.SRID): + + self.connection = pgdb.connect(host=initial_host, + database=initial_database, + user=initial_username) + self.srid = initial_srid def __del__(self): diff --git a/src/Tests/Unit/CensusTest.py b/src/Tests/Unit/CensusTest.py index dd18e7c..0789e2f 100644 --- a/src/Tests/Unit/CensusTest.py +++ b/src/Tests/Unit/CensusTest.py @@ -1,8 +1,6 @@ import unittest import Census -import Configuration.Defaults -import GPS import SummaryFile1 import Tests.Fixtures @@ -10,10 +8,7 @@ import Tests.Fixtures class DatabaseTest(unittest.TestCase): def setUp(self): - self.cdb = Census.Database(Configuration.Defaults.DATABASE_HOST, - Configuration.Defaults.DATABASE_NAME, - Configuration.Defaults.DATABASE_USERNAME, - Configuration.Defaults.SRID) + self.cdb = Census.Database() def testEachBlockContainsItsOwnPopulation(self):