]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Moved the default initialization for the Census class in to its constructor.
authorMichael Orlitzky <michael@orlitzky.com>
Sat, 3 Oct 2009 20:51:26 +0000 (16:51 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Sat, 3 Oct 2009 20:51:26 +0000 (16:51 -0400)
Removed an unnecessary GPS import from CensusTest.

src/Census.py
src/Tests/Unit/CensusTest.py

index da9283d2efb20c4c7d1f8896b120fad8f98b3815..63f69aaccaadf355b7d1b82414841e1d2839111b 100644 (file)
@@ -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):
index dd18e7c3c7fd3c56b59402dbdf1e3cf3f7df2a27..0789e2fe6b897357f359399aeb5cff2f32402f71 100644 (file)
@@ -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):