Coverage for tests/test_tutorial/test_sql_databases/test_testing_databases_py39.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-08-08 03:53 +0000

1import importlib 1eabcd

2import os 1eabcd

3from pathlib import Path 1eabcd

4 

5import pytest 1eabcd

6 

7from ...utils import needs_py39, needs_pydanticv1 1eabcd

8 

9 

10@needs_py39 1eabcd

11# TODO: pv2 add version with Pydantic v2 

12@needs_pydanticv1 1eabcd

13def test_testing_dbs_py39(tmp_path_factory: pytest.TempPathFactory): 1eabcd

14 tmp_path = tmp_path_factory.mktemp("data") 1abcd

15 cwd = os.getcwd() 1abcd

16 os.chdir(tmp_path) 1abcd

17 test_db = Path("./test.db") 1abcd

18 if test_db.is_file(): # pragma: nocover 1abcd

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_py39.tests import test_sql_app 1abcd

22 

23 # Ensure import side effects are re-executed 

24 importlib.reload(test_sql_app) 1abcd

25 test_sql_app.test_create_user() 1abcd

26 if test_db.is_file(): # pragma: nocover 1abcd

27 test_db.unlink() 1abcd

28 os.chdir(cwd) 1abcd