Re: tests/run.py raises error if no postgres adaptor is installed

Sebastien Bigaret <[email protected]> 17 Mar 2004 08:19:30 +0100
Newsgroups gmane.comp.python.modeling
Message-ID <[email protected]>
"Ernesto Revilla" <[email protected]> wrote:
> Hi,
> 
> under python 2.3 with sqlite adaptor installed but no postgres I got this when running Modeling/tests/run.py:
> 
> Modeling.Adaptor.GeneralAdaptorException: Unable to find either psycopg, pgdb or  pypgsql
> 

Right, we can consider this as a bug: the absence of underlying py
adaptor for PostgresqlAdaptor shouldn't raise a fatal error (maybe just
a warning) until it is really needed --which is not the case at import
time. If you find some time, please submit a bug report at sf.

  You'll find attached a quick-n-dirty patch. Thanks for reporting!

-- Sébastien.


Index: test_SchemaGeneration.py
===================================================================
RCS file: /cvsroot/modeling/ProjectModeling/Modeling/tests/test_SchemaGeneration.py,v
retrieving revision 1.6
diff -u -r1.6 test_SchemaGeneration.py
--- test_SchemaGeneration.py    14 Feb 2004 18:17:21 -0000      1.6
+++ test_SchemaGeneration.py    17 Mar 2004 06:48:36 -0000
@@ -62,6 +62,11 @@
   modelSet=ModelSet.ModelSet()
   modelSet.addModelFromXML({'file': xmlmodelPath})
   model=modelSet.modelNamed('simpleModel1')
+  try:
+    import psycopg
+  except ImportError:
+    import sys
+    sys.modules['psycopg']=1
   pgAdaptor=Adaptor.adaptorWithModel(model)
 
 class TestSchemaGeneration(unittest.TestCase):



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id70&alloc_id638&op=click