File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ requests
18
18
asynctest
19
19
psycopg2
20
20
pyodbc
21
+ schemathesis
21
22
22
23
# Linting
23
24
flake8
Original file line number Diff line number Diff line change
1
+ import pytest
2
+ import schemathesis
3
+ from fastapi import FastAPI
4
+ from schemathesis .specs .openapi .schemas import BaseOpenAPISchema
5
+
6
+
7
+ @pytest .fixture ()
8
+ def app_schema (client ) -> BaseOpenAPISchema :
9
+ """
10
+ Get an OpenAPI schema instance for the app created by the `client` fixture.
11
+ """
12
+ app : FastAPI = client .app
13
+ assert client .app is not None
14
+ openapi = app .openapi ()
15
+ result = schemathesis .from_dict (openapi )
16
+ return result
17
+
18
+
19
+ schema = schemathesis .from_pytest_fixture ("app_schema" )
20
+
21
+
22
+ @schema .parametrize ()
23
+ def test_api (case ):
24
+ """Run tests automatically generated by schemathesis."""
25
+ case .call_and_validate ()
You can’t perform that action at this time.
0 commit comments