Re: Running installation tests
Gerhard Häring <[email protected]>
| Newsgroups | gmane.comp.python.db.pypgsql.user |
|---|---|
| Organization | OPUS GmbH |
| Message-ID | <[email protected]> |
Mario Ruggier <[email protected]> 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: > >====================================================================== > ERROR: CheckCloseConnection (__main__.PgSQLTestCases) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "test/PgSQLTestCases.py", line 401, in setUp > self.cnx = PgSQL.connect(database='template1') > File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 2118, > in connect > return Connection(connInfo, client_encoding, unicode_results) > File "/usr/lib/python2.2/site-packages/pyPgSQL/PgSQL.py", line 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. It's all documented there. Longer answer: This is a corner of pyPgSQL that needs some work. I think we should make the database connection for the test cases configurable. Perhaps by use of a configuration file, perhaps by use of an 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 like export DSN="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 ./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. | #-----------------------------------------------------------------------+ ! import sys import unittest import types import string --- 82,88 ---- # ify the test(s) accordingly. | # 01OCT2000 bga Initial release by Billy G. Allie. | #-----------------------------------------------------------------------+ ! import os, sys import unittest import types import string *************** *** 398,404 **** class PgSQLTestCases(unittest.TestCase): def setUp(self): ! self.cnx = PgSQL.connect(database='template1') self.cur = self.cnx.cursor() self.vstr = "%(major)d.%(minor)d" % self.cnx.version if self.cnx.version < '7.3': --- 398,404 ---- class PgSQLTestCases(unittest.TestCase): def setUp(self): ! self.cnx = PgSQL.connect(dsn=DSN, database='template1') self.cur = self.cnx.cursor() self.vstr = "%(major)d.%(minor)d" % self.cnx.version if self.cnx.version < '7.3': *************** *** 848,854 **** class PgResultSetTests(unittest.TestCase): def setUp(self): ! self.cnx = PgSQL.connect(database='template1') self.cur = self.cnx.cursor() def tearDown(self): --- 848,854 ---- class PgResultSetTests(unittest.TestCase): def setUp(self): ! self.cnx = PgSQL.connect(dsn=DSN, database='template1') self.cur = self.cnx.cursor() def tearDown(self): *************** *** 983,988 **** --- 983,990 ---- return test_suite def main(): + global DSN + DSN = os.environ.get("DSN", "") runner = 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