0

I am working with Schemathesis and pytest. I came across with a problem of serializing 'application/xml' content-type as Schemathesis can't do it out of the box. However, it allows to create a custom serializer to process any content type according to their documentation.

Once I created a serializer I noticed that Schemathesis does not see it. I don't understand what's wrong with it and unfortunately there is not much information about it.

Here is the example:

import schemathesis


@schemathesis.serializers.register("application/xml")
class XmlSerializer:

    def as_requests(self, context, payload):
        print("as_requests")
        return {"data": "someData"}

    def as_werkzeug(self, context, payload):
        print("as_werkzeug")
        return {"data": "someData"}

When I put a breakpoint, it doesn't stop on it and it does not print the values. I would appreciate if you can help me to figure out what is wrong here.

  • You need to specify the Python module where this code is located in the `--pre-run` CLI option if you use Schemathesis CLI. For `pytest` it should work out of the box if you import this module in your tests. How do you run Schemathesis? – Stranger6667 Jan 31 '23 at 21:58

0 Answers0