Discussion:
[Modeling-users] tests/run.py raises error if no postgres adaptor is installed
Ernesto Revilla
2004-03-16 23:48:03 UTC
Permalink
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

Erny
Sebastien Bigaret
2004-03-17 05:20:04 UTC
Permalink
Post by Ernesto Revilla
Hi,
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):

Loading...