Skip to content

Commit 75a79a3

Browse files
authored
✅ Refactor tests to use autouse clear_sqlmodel (#1406)
1 parent d42c85f commit 75a79a3

28 files changed

+32
-32
lines changed

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
docs_src_path = top_level_path / "docs_src"
1515

1616

17-
@pytest.fixture()
18-
def clear_sqlmodel():
17+
@pytest.fixture(autouse=True)
18+
def clear_sqlmodel() -> Any:
1919
# Clear the tables in the metadata for the default base model
2020
SQLModel.metadata.clear()
2121
# Clear the Models associated with the registry, to avoid warnings

tests/test_advanced/test_decimal/test_tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
]
3131

3232

33-
def test_tutorial(clear_sqlmodel):
33+
def test_tutorial():
3434
from docs_src.advanced.decimal import tutorial001 as mod
3535

3636
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_decimal/test_tutorial001_py310.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232

3333
@needs_py310
34-
def test_tutorial(clear_sqlmodel):
34+
def test_tutorial():
3535
from docs_src.advanced.decimal import tutorial001_py310 as mod
3636

3737
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_uuid/test_tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ...conftest import get_testing_print_function
77

88

9-
def test_tutorial(clear_sqlmodel) -> None:
9+
def test_tutorial() -> None:
1010
from docs_src.advanced.uuid import tutorial001 as mod
1111

1212
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_uuid/test_tutorial001_py310.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
@needs_py310
10-
def test_tutorial(clear_sqlmodel) -> None:
10+
def test_tutorial() -> None:
1111
from docs_src.advanced.uuid import tutorial001_py310 as mod
1212

1313
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_uuid/test_tutorial002.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ...conftest import get_testing_print_function
77

88

9-
def test_tutorial(clear_sqlmodel) -> None:
9+
def test_tutorial() -> None:
1010
from docs_src.advanced.uuid import tutorial002 as mod
1111

1212
mod.sqlite_url = "sqlite://"

tests/test_advanced/test_uuid/test_tutorial002_py310.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99
@needs_py310
10-
def test_tutorial(clear_sqlmodel) -> None:
10+
def test_tutorial() -> None:
1111
from docs_src.advanced.uuid import tutorial002_py310 as mod
1212

1313
mod.sqlite_url = "sqlite://"

tests/test_tutorial/test_automatic_id_none_refresh/test_tutorial001_tutorial002.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]):
133133
]
134134

135135

136-
def test_tutorial_001(clear_sqlmodel):
136+
def test_tutorial_001():
137137
from docs_src.tutorial.automatic_id_none_refresh import tutorial001 as mod
138138

139139
mod.sqlite_url = "sqlite://"
@@ -147,7 +147,7 @@ def test_tutorial_001(clear_sqlmodel):
147147
check_calls(calls)
148148

149149

150-
def test_tutorial_002(clear_sqlmodel):
150+
def test_tutorial_002():
151151
from docs_src.tutorial.automatic_id_none_refresh import tutorial002 as mod
152152

153153
mod.sqlite_url = "sqlite://"

tests/test_tutorial/test_code_structure/test_tutorial001.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
]
2323

2424

25-
def test_tutorial(clear_sqlmodel):
25+
def test_tutorial():
2626
from docs_src.tutorial.code_structure.tutorial001 import app, database
2727

2828
database.sqlite_url = "sqlite://"

tests/test_tutorial/test_code_structure/test_tutorial001_py310.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
@needs_py310
26-
def test_tutorial(clear_sqlmodel):
26+
def test_tutorial():
2727
from docs_src.tutorial.code_structure.tutorial001_py310 import app, database
2828

2929
database.sqlite_url = "sqlite://"

0 commit comments

Comments
 (0)