Skip to content

Commit 0f5fadf

Browse files
committed
✅ Revert removing tests, update them for Python 3.10
1 parent 4cf93cf commit 0f5fadf

2 files changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import importlib
2+
3+
import pytest
4+
from sqlmodel import Session
5+
6+
from docs_src.tutorial.fastapi.app_testing.tutorial001_py310 import main as app_mod
7+
from docs_src.tutorial.fastapi.app_testing.tutorial001_py310 import (
8+
test_main_005 as test_mod,
9+
)
10+
from docs_src.tutorial.fastapi.app_testing.tutorial001_py310.test_main_005 import (
11+
session_fixture,
12+
)
13+
14+
assert session_fixture, "This keeps the session fixture used below"
15+
16+
17+
@pytest.fixture(name="prepare")
18+
def prepare_fixture(clear_sqlmodel):
19+
# Trigger side effects of registering table models in SQLModel
20+
# This has to be called after clear_sqlmodel, but before the session_fixture
21+
# That's why the extra custom fixture here
22+
importlib.reload(app_mod)
23+
24+
25+
def test_tutorial(prepare, session: Session):
26+
test_mod.test_create_hero(session)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import importlib
2+
3+
import pytest
4+
from fastapi.testclient import TestClient
5+
from sqlmodel import Session
6+
7+
from docs_src.tutorial.fastapi.app_testing.tutorial001_py310 import main as app_mod
8+
from docs_src.tutorial.fastapi.app_testing.tutorial001_py310 import (
9+
test_main_006 as test_mod,
10+
)
11+
from docs_src.tutorial.fastapi.app_testing.tutorial001_py310.test_main_006 import (
12+
client_fixture,
13+
session_fixture,
14+
)
15+
16+
assert session_fixture, "This keeps the session fixture used below"
17+
assert client_fixture, "This keeps the client fixture used below"
18+
19+
20+
@pytest.fixture(name="prepare")
21+
def prepare_fixture(clear_sqlmodel):
22+
# Trigger side effects of registering table models in SQLModel
23+
# This has to be called after clear_sqlmodel, but before the session_fixture
24+
# That's why the extra custom fixture here
25+
importlib.reload(app_mod)
26+
27+
28+
def test_tutorial(prepare, session: Session, client: TestClient):
29+
test_mod.test_create_hero(client)

0 commit comments

Comments
 (0)