Hi,

I'm trying to use WebTest with pytest and Cornice. I have defined an 
endpoint that I can manually test with Postman with no issues. I try to 
test the same endpoint with:

class TestInvoice:
    def test_create_invoice(self, app):
        resp = app.post_json(COLLECTION_PATH, dict(customer=1, value="Test 
customer"))
        assert resp.json["customer"] == "Test customer"

But I get the following error:

self = <Service collection_invoice at /invoices>
request = <Request at 0x104a490a0 POST http://localhost/invoices>

def default_error_handler(self, request):
    """Default error_handler.

    Uses the renderer for the service to render `request.errors`.
    Only works if the registered renderer for the Service exposes the
    method `render_errors`, which is implemented by default by
    :class:`cornice.renderer.CorniceRenderer`.

    :param request: the current Request.
    """
    renderer = request.registry.queryUtility(
        IRendererFactory, name=self.renderer
    )
    > return renderer.render_errors(request)
    E AttributeError: 'JSON' object has no attribute 'render_errors'

../../.virtualenvs/cloud_service/lib/python3.9/site-packages/cornice/service.py:228:
 
AttributeError

I don't use the default JSON renderer, I wanted to use simplejson and 
marshmallow, so I replaced it with:

json_renderer = JSON(serializer=simplejson.dumps)
json_renderer.add_adapter(decimal.Decimal, simplejson.dumps)
config.add_renderer("json", json_renderer)

Is my renderer setup incorrect? I looked at the Cornice API, but I'm a bit 
stuck trying to figure it out.

Thanks,
Sergi

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/4594cde1-5fb7-4b70-b381-ff9c6692ed27n%40googlegroups.com.

Reply via email to