Edgewall Software
Modify

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#9988 closed defect (fixed)

test_multiple_cookies fails with python 2.4.3

Reported by: Jun Omae Owned by: Remy Blank
Priority: normal Milestone: 0.12.2
Component: general Version: 0.12-stable
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

test_multiple_cookies fails with python 2.4.3. It passes with python 2.5.2 and 2.6.4.

It seems that Cookie.BaseCookie is different between 2.4.3 and 2.5.2.

Python 2.4.3

jun66j5@gotanda:1012$ python
Python 2.4.3 (#1, Nov 11 2010, 13:34:43)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Cookie import BaseCookie
>>> str(BaseCookie('key=value'))
'Set-Cookie: key=value;'

Python 2.5.2

jun66j5@localhost:326$ python
Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Cookie import BaseCookie
>>> str(BaseCookie('key=value'))
'Set-Cookie: key=value'
jun66j5@gotanda:999$ make unit-test
Python version: Python 2.4.3
figleaf:
coverage:
PYTHONPATH=.:
TRAC_TEST_DB_URI=
server-options= -p 8000  -r -e
python setup.py egg_info
running egg_info
writing requirements to Trac.egg-info/requires.txt
writing Trac.egg-info/PKG-INFO
writing top-level names to Trac.egg-info/top_level.txt
writing dependency_links to Trac.egg-info/dependency_links.txt
writing entry points to Trac.egg-info/entry_points.txt
writing manifest file 'Trac.egg-info/SOURCES.txt'
python ./trac/test.py --skip-functional-tests
.........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................F.............................................................................................................................................................................................................................................................................................................................................................................................................
======================================================================
FAIL: test_multiple_cookies (trac.web.tests.api.RequestTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/trac/0.12-stable/trac/web/tests/api.py", line 119, in test_multiple_cookies
    self.assertEqual('Set-Cookie: key=value1', str(req.incookie))
AssertionError: 'Set-Cookie: key=value1' != 'Set-Cookie: key=value1;'

----------------------------------------------------------------------
Ran 1127 tests in 46.697s

FAILED (failures=1)
make: *** [unit-test] Error 1

Attachments (0)

Change History (6)

comment:1 by Remy Blank, 13 years ago

Right, so they changed the serialization of cookies after 2.4. The following patch should make the test pass with both variants:

  • trac/web/tests/api.py

    diff --git a/trac/web/tests/api.py b/trac/web/tests/api.py
    a b class RequestTestCase(unittest.TestCase)  
    116116    def test_multiple_cookies(self):
    117117        environ = self._make_environ(HTTP_COOKIE='key=value1; key=value2;')
    118118        req = Request(environ, None)
    119         self.assertEqual('Set-Cookie: key=value1', str(req.incookie))
     119        self.assertEqual('Set-Cookie: key=value1',
     120                         str(req.incookie).rstrip(';'))
    120121
    121122    def test_read(self):
    122123        environ = self._make_environ(**{'wsgi.input': StringIO('test input')})

comment:2 by Remy Blank, 13 years ago

Resolution: fixed
Status: newclosed

Fixed in [10449] (the test was introduced to check the fix for #9951). Thanks for the heads-up!

comment:3 by Remy Blank, 13 years ago

Owner: set to Remy Blank

comment:4 by Christian Boos, 13 years ago

Was [10450] really necessary? As we don't support 2.4 there I think it's OK if the test remains in its original, stricter, form.

in reply to:  4 ; comment:5 by Remy Blank, 13 years ago

Replying to cboos:

Was [10450] really necessary? As we don't support 2.4 there I think it's OK if the test remains in its original, stricter, form.

It wasn't absolutely necessary, but I remember thinking that the test was a bit sensitive to small changes in the serialization, and this issue was a confirmation. The "stricter" form doesn't buy anything anyway, as both serializations are valid. So I prefer the "weaker" form.

in reply to:  5 comment:6 by Christian Boos, 13 years ago

Replying to rblank:

… The "stricter" form doesn't buy anything anyway, as both serializations are valid.

Ah, I see. Thanks for the explanation!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.