Coverage for tests/test_tutorial/test_sql_databases/test_testing_databases_py310.py: 100%
16 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-08-08 03:53 +0000
1import importlib 1deabc
2import os 1deabc
3from pathlib import Path 1deabc
5import pytest 1deabc
7from ...utils import needs_py310, needs_pydanticv1 1deabc
10@needs_py310 1deabc
11# TODO: pv2 add version with Pydantic v2
12@needs_pydanticv1 1deabc
13def test_testing_dbs_py39(tmp_path_factory: pytest.TempPathFactory): 1deabc
14 tmp_path = tmp_path_factory.mktemp("data") 1abc
15 cwd = os.getcwd() 1abc
16 os.chdir(tmp_path) 1abc
17 test_db = Path("./test.db") 1abc
18 if test_db.is_file(): # pragma: nocover 1abc
19 test_db.unlink()
20 # Import while creating the client to create the DB after starting the test session
21 from docs_src.sql_databases.sql_app_py310.tests import test_sql_app 1abc
23 # Ensure import side effects are re-executed
24 importlib.reload(test_sql_app) 1abc
25 test_sql_app.test_create_user() 1abc
26 if test_db.is_file(): # pragma: nocover 1abc
27 test_db.unlink() 1abc
28 os.chdir(cwd) 1abc