Skip to content

Commit

Permalink
✅ Require Python 3.9 and 3.10 for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tiangolo committed Nov 29, 2023
1 parent 9f5d5ea commit c6cedb3
Show file tree
Hide file tree
Showing 94 changed files with 230 additions and 62 deletions.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import shutil
import subprocess
import sys
from pathlib import Path
from typing import Any, Callable, Dict, List, Union

Expand Down Expand Up @@ -67,3 +68,9 @@ def new_print(*args):
calls.append(data)

return new_print


needs_py39 = pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python3.9+")
needs_py310 = pytest.mark.skipif(
sys.version_info < (3, 10), reason="requires python3.10+"
)
3 changes: 2 additions & 1 deletion tests/test_advanced/test_decimal/test_tutorial001_py310.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from sqlmodel import create_engine

from ...conftest import get_testing_print_function
from ...conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand All @@ -30,6 +30,7 @@
]


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.advanced.decimal import tutorial001_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from sqlmodel import create_engine

from tests.conftest import get_testing_print_function
from tests.conftest import get_testing_print_function, needs_py310


def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]):
Expand Down Expand Up @@ -133,6 +133,7 @@ def check_calls(calls: List[List[Union[str, Dict[str, Any]]]]):
]


@needs_py310
def test_tutorial_001(clear_sqlmodel):
from docs_src.tutorial.automatic_id_none_refresh import tutorial001_py310 as mod

Expand All @@ -147,6 +148,7 @@ def test_tutorial_001(clear_sqlmodel):
check_calls(calls)


@needs_py310
def test_tutorial_002(clear_sqlmodel):
from docs_src.tutorial.automatic_id_none_refresh import tutorial002_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ...conftest import get_testing_print_function
from ...conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand All @@ -22,6 +22,7 @@
]


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.code_structure.tutorial001_py310 import app, database

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ...conftest import get_testing_print_function
from ...conftest import get_testing_print_function, needs_py39

expected_calls = [
[
Expand All @@ -22,6 +22,7 @@
]


@needs_py39
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.code_structure.tutorial001_py39 import app, database

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ...conftest import get_testing_print_function
from ...conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand All @@ -22,6 +22,7 @@
]


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.code_structure.tutorial002_py310 import app, database

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ...conftest import get_testing_print_function
from ...conftest import get_testing_print_function, needs_py39

expected_calls = [
[
Expand All @@ -22,6 +22,7 @@
]


@needs_py39
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.code_structure.tutorial002_py39 import app, database

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from sqlalchemy.engine.reflection import Inspector
from sqlmodel import create_engine

from ....conftest import needs_py310


@needs_py310
def test_tutorial001(clear_sqlmodel):
from docs_src.tutorial.connect.create_tables import tutorial001_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ....conftest import get_testing_print_function
from ....conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand Down Expand Up @@ -58,6 +58,7 @@
]


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.connect.delete import tutorial001_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ....conftest import get_testing_print_function
from ....conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand Down Expand Up @@ -38,6 +38,7 @@
]


@needs_py310
def test_tutorial001(clear_sqlmodel):
from docs_src.tutorial.connect.insert import tutorial001_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ....conftest import get_testing_print_function
from ....conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand Down Expand Up @@ -62,6 +62,7 @@
]


@needs_py310
def test_tutorial001(clear_sqlmodel):
from docs_src.tutorial.connect.select import tutorial001_py310 as mod

Expand All @@ -76,6 +77,7 @@ def test_tutorial001(clear_sqlmodel):
assert calls == expected_calls


@needs_py310
def test_tutorial002(clear_sqlmodel):
from docs_src.tutorial.connect.select import tutorial002_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ....conftest import get_testing_print_function
from ....conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand Down Expand Up @@ -74,6 +74,7 @@
]


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.connect.select import tutorial003_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ....conftest import get_testing_print_function
from ....conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand Down Expand Up @@ -48,6 +48,7 @@
]


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.connect.select import tutorial004_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ....conftest import get_testing_print_function
from ....conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand Down Expand Up @@ -50,6 +50,7 @@
]


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.connect.select import tutorial005_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ....conftest import get_testing_print_function
from ....conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand Down Expand Up @@ -48,6 +48,7 @@
]


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.connect.update import tutorial001_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from pathlib import Path

from ...conftest import coverage_run
from ...conftest import coverage_run, needs_py310


@needs_py310
def test_create_db_and_table(cov_tmp_path: Path):
module = "docs_src.tutorial.create_db_and_table.tutorial001_py310"
result = coverage_run(module=module, cwd=cov_tmp_path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from sqlalchemy.engine.reflection import Inspector
from sqlmodel import create_engine

from ...conftest import needs_py310


@needs_py310
def test_create_db_and_table(clear_sqlmodel):
from docs_src.tutorial.create_db_and_table import tutorial002_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from sqlalchemy.engine.reflection import Inspector
from sqlmodel import create_engine

from ...conftest import needs_py310


@needs_py310
def test_create_db_and_table(clear_sqlmodel):
from docs_src.tutorial.create_db_and_table import tutorial003_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from sqlmodel import create_engine

from ...conftest import get_testing_print_function
from ...conftest import get_testing_print_function, needs_py310

expected_calls = [
[
Expand Down Expand Up @@ -58,6 +58,7 @@
]


@needs_py310
def test_tutorial001(clear_sqlmodel):
from docs_src.tutorial.delete import tutorial001_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import subprocess
from pathlib import Path

from ....conftest import needs_py310


@needs_py310
def test_run_tests(clear_sqlmodel):
from docs_src.tutorial.fastapi.app_testing.tutorial001_py310 import test_main as mod

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import subprocess
from pathlib import Path

from ....conftest import needs_py39


@needs_py39
def test_run_tests(clear_sqlmodel):
from docs_src.tutorial.fastapi.app_testing.tutorial001_py39 import test_main as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from sqlmodel import create_engine
from sqlmodel.pool import StaticPool

from ....conftest import needs_py310


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.fastapi.delete import tutorial001_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from sqlmodel import create_engine
from sqlmodel.pool import StaticPool

from ....conftest import needs_py39


@needs_py39
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.fastapi.delete import tutorial001_py39 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from sqlmodel import create_engine
from sqlmodel.pool import StaticPool

from ....conftest import needs_py310


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.fastapi.limit_and_offset import tutorial001_py310 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from sqlmodel import create_engine
from sqlmodel.pool import StaticPool

from ....conftest import needs_py39


@needs_py39
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.fastapi.limit_and_offset import tutorial001_py39 as mod

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from sqlmodel import create_engine
from sqlmodel.pool import StaticPool

from ....conftest import needs_py310


@needs_py310
def test_tutorial(clear_sqlmodel):
from docs_src.tutorial.fastapi.multiple_models import tutorial001_py310 as mod

Expand Down
Loading

0 comments on commit c6cedb3

Please sign in to comment.