You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Graham Dumpleton <gr...@dscpl.com.au> on 2006/02/04 07:19:18 UTC

Change to test_Session_Session_conf() of test/test.py.

Jim, Nicolas

Would it make sense to change test_Session_Session_conf() function in
unit tests to something like:

     def test_Session_Session_conf(self):

         import tempfile
         tempdir = tempfile.gettempdir()
         database = os.path.join(tempdir,"mp_sess_test.dbm")

         c = VirtualHost("*",
                         ServerName("test_Session_Session"),
                         DocumentRoot(DOCUMENT_ROOT),
                         Directory(DOCUMENT_ROOT,
                                   PythonOption('session_dbm "%s"' % 
database),
                                   SetHandler("mod_python"),
                                   
PythonHandler("tests::Session_Session"),
                                   PythonDebug("On")))
         return str(c)

Ie., explicitly set "session_dbm" to some other location than default.
Without this the test can fail if main Apache is run as different
account to what test is run as. I put database in "/tmp" under a 
different
name, but might be better somewhere in the test directory of the source 
code.

Does this make sense?

That gets rid of one of the failures, now for the others. :-)

Graham


Re: Change to test_Session_Session_conf() of test/test.py.

Posted by Graham Dumpleton <gr...@dscpl.com.au>.
I'll at least add a JIRA issue then for something to be done about this
for 3.3 and reference this email thread.

I'll probably have a couple of others to add related to tests anyway, 
as I
reckon I can change tests slightly so that they will work on a virtual
hosting system such as OpenVPS.

On 05/02/2006, at 12:46 AM, Jim Gallacher wrote:

> Nicolas Lehuen wrote:
>> 2006/2/4, Graham Dumpleton <gr...@dscpl.com.au>:
>>> Jim, Nicolas
>>>
>>> Would it make sense to change test_Session_Session_conf() function in
>>> unit tests to something like:
>>>
>>>     def test_Session_Session_conf(self):
>>>
>>>         import tempfile
>>>         tempdir = tempfile.gettempdir()
>>>         database = os.path.join(tempdir,"mp_sess_test.dbm")
>>>
>>>         c = VirtualHost("*",
>>>                         ServerName("test_Session_Session"),
>>>                         DocumentRoot(DOCUMENT_ROOT),
>>>                         Directory(DOCUMENT_ROOT,
>>>                                   PythonOption('session_dbm "%s"' %
>>> database),
>>>                                   SetHandler("mod_python"),
>>>
>>> PythonHandler("tests::Session_Session"),
>>>                                   PythonDebug("On")))
>>>         return str(c)
>>>
>>> Ie., explicitly set "session_dbm" to some other location than 
>>> default.
>>> Without this the test can fail if main Apache is run as different
>>> account to what test is run as. I put database in "/tmp" under a
>>> different
>>> name, but might be better somewhere in the test directory of the 
>>> source
>>> code.
>>>
>>> Does this make sense?
>> Of course, no problem ! I agree with you that it would be better if
>> the session file was in the local directory, making sure it is removed
>> before the test runs. Maybe the unit test could open the session dbm
>> after the test has run to check whether the session is saved, for
>> additional safety.
>
> Good idea. Also, I think any temp files created should be put in the 
> local directory and removed after the tests run. The obvious place 
> would be test/tmp.
>
> Also, I just realized that we don't have a unit test for FileSession, 
> which is my fault, since I didn't write one. I shall rectify that, but 
> not for the 3.2.7 release. ;)
>
> Jim
>


Re: Change to test_Session_Session_conf() of test/test.py.

Posted by Jim Gallacher <jp...@jgassociates.ca>.
Nicolas Lehuen wrote:
> 2006/2/4, Graham Dumpleton <gr...@dscpl.com.au>:
> 
>>Jim, Nicolas
>>
>>Would it make sense to change test_Session_Session_conf() function in
>>unit tests to something like:
>>
>>     def test_Session_Session_conf(self):
>>
>>         import tempfile
>>         tempdir = tempfile.gettempdir()
>>         database = os.path.join(tempdir,"mp_sess_test.dbm")
>>
>>         c = VirtualHost("*",
>>                         ServerName("test_Session_Session"),
>>                         DocumentRoot(DOCUMENT_ROOT),
>>                         Directory(DOCUMENT_ROOT,
>>                                   PythonOption('session_dbm "%s"' %
>>database),
>>                                   SetHandler("mod_python"),
>>
>>PythonHandler("tests::Session_Session"),
>>                                   PythonDebug("On")))
>>         return str(c)
>>
>>Ie., explicitly set "session_dbm" to some other location than default.
>>Without this the test can fail if main Apache is run as different
>>account to what test is run as. I put database in "/tmp" under a
>>different
>>name, but might be better somewhere in the test directory of the source
>>code.
>>
>>Does this make sense?
> 
> 
> Of course, no problem ! I agree with you that it would be better if
> the session file was in the local directory, making sure it is removed
> before the test runs. Maybe the unit test could open the session dbm
> after the test has run to check whether the session is saved, for
> additional safety.

Good idea. Also, I think any temp files created should be put in the 
local directory and removed after the tests run. The obvious place would 
be test/tmp.

Also, I just realized that we don't have a unit test for FileSession, 
which is my fault, since I didn't write one. I shall rectify that, but 
not for the 3.2.7 release. ;)

Jim



Re: Change to test_Session_Session_conf() of test/test.py.

Posted by Nicolas Lehuen <ni...@gmail.com>.
2006/2/4, Graham Dumpleton <gr...@dscpl.com.au>:
> Jim, Nicolas
>
> Would it make sense to change test_Session_Session_conf() function in
> unit tests to something like:
>
>      def test_Session_Session_conf(self):
>
>          import tempfile
>          tempdir = tempfile.gettempdir()
>          database = os.path.join(tempdir,"mp_sess_test.dbm")
>
>          c = VirtualHost("*",
>                          ServerName("test_Session_Session"),
>                          DocumentRoot(DOCUMENT_ROOT),
>                          Directory(DOCUMENT_ROOT,
>                                    PythonOption('session_dbm "%s"' %
> database),
>                                    SetHandler("mod_python"),
>
> PythonHandler("tests::Session_Session"),
>                                    PythonDebug("On")))
>          return str(c)
>
> Ie., explicitly set "session_dbm" to some other location than default.
> Without this the test can fail if main Apache is run as different
> account to what test is run as. I put database in "/tmp" under a
> different
> name, but might be better somewhere in the test directory of the source
> code.
>
> Does this make sense?

Of course, no problem ! I agree with you that it would be better if
the session file was in the local directory, making sure it is removed
before the test runs. Maybe the unit test could open the session dbm
after the test has run to check whether the session is saved, for
additional safety.

Regards,
Nicolas

>
> That gets rid of one of the failures, now for the others. :-)
>
> Graham
>
>