Skip to content

Commit

Permalink
use BytesIO while setting up test Response
Browse files Browse the repository at this point in the history
HTTPResponse uses bytes, not string

However, sys.stdout uses string
  • Loading branch information
gotcha committed Jun 17, 2024
1 parent 1727cf9 commit eb99ff4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/plone/testing/zope.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def setRoles(userFolder, userId, roles):

def makeTestRequest(environ=None):
"""Return an HTTPRequest object suitable for testing views."""
from io import BytesIO
from sys import stdin
from sys import stdout
from zope.publisher.browser import setDefaultSkin
from ZPublisher.HTTPRequest import HTTPRequest
from ZPublisher.HTTPResponse import HTTPResponse
Expand All @@ -187,7 +187,7 @@ def makeTestRequest(environ=None):
environ.setdefault("SERVER_PORT", "80")
environ.setdefault("REQUEST_METHOD", "GET")

resp = HTTPResponse(stdout=stdout)
resp = HTTPResponse(stdout=BytesIO())
req = HTTPRequest(stdin, environ, resp)
req._steps = ["noobject"] # Fake a published object.
req["ACTUAL_URL"] = req.get("URL")
Expand Down

0 comments on commit eb99ff4

Please sign in to comment.