From: Mario R. <ma...@ru...> - 2003-01-22 09:18:14
|
Thanks. So my conclusion (in my just-sent 2nd email) is correct. Following up, wouldn't it be even simpler to introduce another file, called test/PySQLTestCasesConfig.py, that simply contains something a dict with parameters for user, password and whatever else may be =20 necessary. The test py imports this dict, and uses the specified values whenever =20= necessary. (This makes it easier to rerun the tests under different conditions, or =20= even to supply these pieces of data dynamically). Cheers, mario ps: I noticed that doing 'reply' to messages on this list will only =20 reply to the individual sender and not to the list. This is on purpose? On mercredi, jan 22, 2003, at 09:52 Europe/Amsterdam, Gerhard H=E4ring =20= wrote: > Mario Ruggier <mario=3Dx...@pu...> wrote: >> Hello, >> >> am installing pyPgSQL 2.3, and seems to be all OK. When I try to run >> the tests (as a user >> for whom there is a postgres user with the same name), i get the >> following error: >> >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> ERROR: CheckCloseConnection (__main__.PgSQLTestCases) >> = ---------------------------------------------------------------------- >> Traceback (most recent call last): >> File "test/PgSQLTestCases.py", line 401, in setUp >> self.cnx =3D PgSQL.connect(database=3D'template1') >> File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line =20 >> 2118, >> in connect >> return Connection(connInfo, client_encoding, unicode_results) >> File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line =20 >> 2215, >> in __init__ >> raise DatabaseError, m >> DatabaseError: fe_sendauth: no password supplied >> >> and similar error foll all subsequent tests. >> >> How do i supply him the password? > > Short answer: in the connect function of the pyPgSQL.PgSQL module. =20 > It's all > documented there. > > Longer answer: This is a corner of pyPgSQL that needs some work. I =20 > think we > should make the database connection for the test cases configurable. > Perhaps by use of a configuration file, perhaps by use of an =20 > environment > variable. Any thoughts on this, Billy? > > The end of this message is a patch that makes it possible to use an > environment variable called 'DSN' for this, so you can do something =20= > like > > export DSN=3D"myhost::myuser:mypassword" > > or whatever is the way to do it in the shell you're using. > > HTH, > > Gerhard > > Patch follows: > > diff -r -C 3 ../pypgsql.orig/test/PgSQLTestCases.py =20 > ./test/PgSQLTestCases.py > *** ../pypgsql.orig/test/PgSQLTestCases.py Wed Jan 22 09:35:08 2003 > --- ./test/PgSQLTestCases.py Wed Jan 22 09:39:48 2003 > *************** > *** 82,88 **** > # ify the test(s) accordingly. = | > # 01OCT2000 bga Initial release by Billy G. Allie. = | > =20 > = #----------------------------------------------------------------------=20= > -+ > ! import sys > import unittest > import types > import string > --- 82,88 ---- > # ify the test(s) accordingly. = | > # 01OCT2000 bga Initial release by Billy G. Allie. = | > =20 > = #----------------------------------------------------------------------=20= > -+ > ! import os, sys > import unittest > import types > import string > *************** > *** 398,404 **** > > class PgSQLTestCases(unittest.TestCase): > def setUp(self): > ! self.cnx =3D PgSQL.connect(database=3D'template1') > self.cur =3D self.cnx.cursor() > self.vstr =3D "%(major)d.%(minor)d" % self.cnx.version > if self.cnx.version < '7.3': > --- 398,404 ---- > > class PgSQLTestCases(unittest.TestCase): > def setUp(self): > ! self.cnx =3D PgSQL.connect(dsn=3DDSN, database=3D'template1') > self.cur =3D self.cnx.cursor() > self.vstr =3D "%(major)d.%(minor)d" % self.cnx.version > if self.cnx.version < '7.3': > *************** > *** 848,854 **** > > class PgResultSetTests(unittest.TestCase): > def setUp(self): > ! self.cnx =3D PgSQL.connect(database=3D'template1') > self.cur =3D self.cnx.cursor() > > def tearDown(self): > --- 848,854 ---- > > class PgResultSetTests(unittest.TestCase): > def setUp(self): > ! self.cnx =3D PgSQL.connect(dsn=3DDSN, database=3D'template1') > self.cur =3D self.cnx.cursor() > > def tearDown(self): > *************** > *** 983,988 **** > --- 983,990 ---- > return test_suite > > def main(): > + global DSN > + DSN =3D os.environ.get("DSN", "") > runner =3D unittest.TextTestRunner() > runner.run(suite()) > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Scholarships for Techies! > Can't afford IT training? All 2003 ictp students receive scholarships. > Get hands-on training in Microsoft, Cisco, Sun, Linux/UNIX, and more. > www.ictp.com/training/sourceforge.asp > _______________________________________________ > Pypgsql-users mailing list > Pyp...@li... > https://lists.sourceforge.net/lists/listinfo/pypgsql-users |