Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
one more test fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
janwijbrand committed Jan 10, 2018
1 parent 290f9c2 commit d173cbd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/grokcore/json/ftests/json/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
JSON views answer a special content-type::
>>> print(http('GET /cave/show HTTP/1.1'))
>>> print(http_call(wsgi_app(), 'GET', '/cave/show'))
HTTP/1.0 200 Ok
Content-Length: 17
Content-Type: application/json
Expand Down
16 changes: 11 additions & 5 deletions src/grokcore/json/ftests/test_functional.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import doctest
import grokcore.json
import re
import six
import unittest
import zope.app.wsgi.testlayer
import zope.testbrowser.wsgi
Expand All @@ -15,7 +16,7 @@ class Layer(
zope.app.wsgi.testlayer.BrowserLayer):
pass

layer = Layer(grokcore.view, allowTearDown=True)
layer = Layer(grokcore.json, allowTearDown=True)


checker = renormalizing.RENormalizing([
Expand All @@ -24,7 +25,7 @@ class Layer(
])


def http_call(method, path, data=None, **kw):
def http_call(app, method, path, data=None, handle_errors=False, **kw):
"""Function to help make RESTful calls.
method - HTTP method to use
Expand All @@ -41,7 +42,12 @@ def http_call(method, path, data=None, **kw):
if data is not None:
request_string += '\r\n'
request_string += data
return http(request_string, handle_errors=False)

if six.PY3:
request_string = request_string.encode()

result = http(app, request_string, handle_errors=handle_errors)
return result


def suiteFromPackage(name):
Expand All @@ -58,9 +64,9 @@ def suiteFromPackage(name):
dottedname,
checker=checker,
extraglobs=dict(
getRootFolder=layer.getRootFolder,
http_call=http_call,
http=http,
getRootFolder=layer.getRootFolder),
wsgi_app=layer.make_wsgi_app),
optionflags=(
doctest.ELLIPSIS +
doctest.NORMALIZE_WHITESPACE +
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ envlist =

[testenv]
commands =
coverage run -m zope.testrunner --test-path=src {posargs:-vc}
coverage run -m zope.testrunner --test-path=src {posargs: -vc}
deps =
.[test]
zope.testrunner
Expand Down

0 comments on commit d173cbd

Please sign in to comment.