File tree Expand file tree Collapse file tree 14 files changed +65
-1658
lines changed Expand file tree Collapse file tree 14 files changed +65
-1658
lines changed Original file line number Diff line number Diff line change
1
+ import importlib
2
+
1
3
import pytest
2
4
from fastapi .testclient import TestClient
3
5
4
- from ...utils import needs_pydanticv2
6
+ from ...utils import needs_py310 , needs_pydanticv2
5
7
6
8
7
- @pytest .fixture (name = "client" )
8
- def get_client ():
9
- from docs_src .schema_extra_example .tutorial001 import app
9
+ @pytest .fixture (
10
+ name = "client" ,
11
+ params = [
12
+ "tutorial001" ,
13
+ pytest .param ("tutorial001_py310" , marks = needs_py310 ),
14
+ ],
15
+ )
16
+ def get_client (request : pytest .FixtureRequest ):
17
+ mod = importlib .import_module (f"docs_src.schema_extra_example.{ request .param } " )
10
18
11
- client = TestClient (app )
19
+ client = TestClient (mod . app )
12
20
return client
13
21
14
22
Original file line number Diff line number Diff line change
1
+ import importlib
2
+
1
3
import pytest
2
4
from fastapi .testclient import TestClient
3
5
4
- from ...utils import needs_pydanticv1
6
+ from ...utils import needs_py310 , needs_pydanticv1
5
7
6
8
7
- @pytest .fixture (name = "client" )
8
- def get_client ():
9
- from docs_src .schema_extra_example .tutorial001_pv1 import app
9
+ @pytest .fixture (
10
+ name = "client" ,
11
+ params = [
12
+ "tutorial001_pv1" ,
13
+ pytest .param ("tutorial001_pv1_py310" , marks = needs_py310 ),
14
+ ],
15
+ )
16
+ def get_client (request : pytest .FixtureRequest ):
17
+ mod = importlib .import_module (f"docs_src.schema_extra_example.{ request .param } " )
10
18
11
- client = TestClient (app )
19
+ client = TestClient (mod . app )
12
20
return client
13
21
14
22
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import importlib
2
+
3
+ import pytest
1
4
from dirty_equals import IsDict
2
5
from fastapi .testclient import TestClient
3
6
4
- from docs_src .schema_extra_example .tutorial004 import app
7
+ from ...utils import needs_py39 , needs_py310
8
+
9
+
10
+ @pytest .fixture (
11
+ name = "client" ,
12
+ params = [
13
+ "tutorial004" ,
14
+ pytest .param ("tutorial004_py310" , marks = needs_py310 ),
15
+ "tutorial004_an" ,
16
+ pytest .param ("tutorial004_an_py39" , marks = needs_py39 ),
17
+ pytest .param ("tutorial004_an_py310" , marks = needs_py310 ),
18
+ ],
19
+ )
20
+ def get_client (request : pytest .FixtureRequest ):
21
+ mod = importlib .import_module (f"docs_src.schema_extra_example.{ request .param } " )
5
22
6
- client = TestClient (app )
23
+ client = TestClient (mod .app )
24
+ return client
7
25
8
26
9
- # Test required and embedded body parameters with no bodies sent
10
- def test_post_body_example ():
27
+ def test_post_body_example (client : TestClient ):
11
28
response = client .put (
12
29
"/items/5" ,
13
30
json = {
@@ -20,7 +37,7 @@ def test_post_body_example():
20
37
assert response .status_code == 200
21
38
22
39
23
- def test_openapi_schema ():
40
+ def test_openapi_schema (client : TestClient ):
24
41
response = client .get ("/openapi.json" )
25
42
assert response .status_code == 200 , response .text
26
43
assert response .json () == {
You can’t perform that action at this time.
0 commit comments