Re: Re: Running installation tests

Mario Ruggier <[email protected]>
Newsgroups gmane.comp.python.db.pypgsql.user
Message-ID <[email protected]>
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  
necessary.
The test py imports this dict, and uses the specified values whenever  
necessary.
(This makes it easier to rerun the tests under different conditions, or  
even to supply
these pieces of data dynamically).

Cheers, mario

ps: I noticed that doing 'reply' to messages on this list will only  
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äring  
wrote:

> 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
> _______________________________________________
> Pypgsql-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pypgsql-users



-------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.