Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1783 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

[PATCH] Decode the response in testutil.BrowsingSession

Reported by: PeterRussell Owned by: kskuhlman
Priority: low Milestone: 1.1b2
Component: Documentation Version: 1.0.4.4
Severity: minor Keywords: needs documentation
Cc:

Description

At present BrowsingSession.response is an str object, rather than a unicode object. In writing unit tests it is often necessary to test for the presence of a substring within the response, but if the substring is a unicode object, then Python will try to decode the response using the ASCII codec, which will fail if any character in the response is not in ASCII, resulting in the dread UnicodeDecodeError.

The attached patch against the 1.0 branch adds a unicode_response field to the browsing session object if an encoding is specified in the Content-Type header. Tests can use this much more safely.

Attachments

browsing-session.patch Download (2.1 KB) - added by PeterRussell 11 years ago.
Patch to add response decoding to BrowsingSession?

Change History

Changed 11 years ago by PeterRussell

Patch to add response decoding to BrowsingSession?

comment:1 Changed 11 years ago by kskuhlman

  • Owner changed from anonymous to kskuhlman
  • Component changed from TurboGears to Documentation

Looks good. Applied in r5176. This needs to be added to the Testing documentation, so leaving ticket open so we don't forget that.

Thanks for the patch!

comment:2 Changed 11 years ago by faide

  • Milestone changed from 1.5 to 1.1

comment:3 Changed 11 years ago by Chris Arndt

  • Keywords needs documentation added
  • Milestone changed from 1.1 to 1.1 beta 2

comment:4 Changed 11 years ago by faide

+1 for having the docs. If you need help Ken just say so...

comment:5 Changed 11 years ago by kskuhlman

  • Status changed from new to closed
  • Resolution set to fixed

Added documentation for BrowsingSession? (including unicode_response) in both the 1.0 & 1.1 versions of the testing docs.

Note: See TracTickets for help on using tickets.