Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow newer WebTest versions. #32

Merged
merged 2 commits into from
Sep 1, 2017
Merged

Allow newer WebTest versions. #32

merged 2 commits into from
Sep 1, 2017

Conversation

icemac
Copy link
Member

@icemac icemac commented Aug 2, 2017

2.0.28 fixed the regressions we saw with 2.0.27.
A big thank you goes to @fschulze for doing bringing up the fix there.

Fixes #30.

2.0.28 fixed the regressions we saw with 2.0.27.
A big thank you goes to @fschulze for doing bringing up the fix there.
@icemac icemac requested a review from mgedmin August 2, 2017 06:48
@icemac
Copy link
Member Author

icemac commented Aug 4, 2017

Could the failures have something to do with Pylons/webtest#186?

Copy link
Member

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So AFAIU the tests fail because of some changes in WebTest 2.0.28? Joy.

It does look like the Zope stack is doing something bad here (passing a unicode object in the HTTP header list argument of start_response()). I cannot say offhand how it happens; some debugging is required.

@fschulze
Copy link
Contributor

This works as a fix:

diff --git a/src/zope/testbrowser/ftests/wsgitestapp.py b/src/zope/testbrowser/ftests/wsgitestapp.py
index 0de6305..a62a311 100644
--- a/src/zope/testbrowser/ftests/wsgitestapp.py
+++ b/src/zope/testbrowser/ftests/wsgitestapp.py
@@ -131,6 +131,10 @@ def set_header(req):
     resp = Response()
     body = [u"Set Headers:"]
     for k, v in sorted(req.params.items()):
+        if not isinstance(k, str):
+            k = k.encode('latin1')
+        if not isinstance(v, str):
+            v = v.encode('latin1')
         body.extend([k, v])
         resp.headers.add(k, v)
     resp.unicode_body = u'\n'.join(body)

I tried several iterations and it only works if it's str on both Python 2 and 3, even though str is actually unicode on Python 3. If I always encode, then it becomes bytes on Python 3 and causes another failure.

@fschulze
Copy link
Contributor

This also works with the older WebTest==2.0.26

Thanks to @fschulze for the patch.
@icemac
Copy link
Member Author

icemac commented Sep 1, 2017

@fschulze Thank you for digging into this issue and finding a solution. Hopefully TravisCI gets green now.

@icemac icemac merged commit e770f7c into master Sep 1, 2017
@icemac icemac deleted the fix-30 branch September 1, 2017 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

new webtest broke our tests
3 participants