Testing
- class tornado_openapi3.testing.AsyncOpenAPITestCase(methodName: str = 'runTest')
A test case that starts up an HTTP server.
An async test case extending
tornado.testing.AsyncHTTPTestCase, providing OpenAPI spec validation on the responses from your application and raising errors in tests.- property spec_dict: dict
The OpenAPI 3 specification
Override this in your test cases to load or define your OpenAPI 3 spec.
- Return type
- property spec: openapi_core.spec.paths.SpecPath
The OpenAPI 3 specification.
Override this in your test cases to customize how your OpenAPI 3 spec is loaded and validated.
- Return type
openapi_core.schema.specs.model.Spec
- property custom_formatters: dict
A dictionary mapping value formats to formatter objects.
A formatter object must provide: - validate(self, value) -> bool - unmarshal(self, value) -> Any
- property custom_media_type_deserializers: dict
A dictionary mapping media types to deserializing functions.
If your endpoints make use of content types beyond
application/json, you must add them to this dictionary with a deserializing method that converts the raw body (asbytesorstr) to Python objects.
- setUp() None
Hook method for setting up the test fixture before exercising it.
Instantiates the
ResponseValidatorfor this test case.
- fetch(path: str, raise_error: bool = False, **kwargs: Any) tornado.httpclient.HTTPResponse
Convenience methiod to synchronously fetch a URL.
Extends the fetch method in Tornado’s :class:
tornado.testing.AsyncHTTPTestCaseto perform OpenAPI 3 validation on the response received before returning it. If validation fails, anopenapi_core.exceptions.OpenAPIErrorwill be raised describing the failure.If the path begins with http:// or https://, it will be treated as a full URL and will be fetched as-is, and no validation will occur.