Coverage for tests/test_tutorial/test_select/test_tutorial003_tutorial004.py: 100%

21 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-16 00:02 +0000

1import importlib 1abcdefghijklm

2from types import ModuleType 1abcdefghijklm

3from typing import Any 1abcdefghijklm

4 

5import pytest 1abcdefghijklm

6from sqlalchemy import Engine 1abcdefghijklm

7 

8from ...conftest import PrintMock 1abcdefghijklm

9 

10 

11def check_calls(calls: list[list[str | dict[str, Any]]]): 1abcdefghijklm

12 assert calls[0][0] == [ 1nopqrstuvwxyzABCDEFGHIJKLM

13 { 

14 "name": "Deadpond", 

15 "secret_name": "Dive Wilson", 

16 "age": None, 

17 "id": 1, 

18 }, 

19 { 

20 "name": "Spider-Boy", 

21 "secret_name": "Pedro Parqueador", 

22 "age": None, 

23 "id": 2, 

24 }, 

25 { 

26 "name": "Rusty-Man", 

27 "secret_name": "Tommy Sharp", 

28 "age": 48, 

29 "id": 3, 

30 }, 

31 ] 

32 

33 

34@pytest.fixture(name="module") 1abcdefghijklm

35def get_module(request: pytest.FixtureRequest, database_engine: Engine) -> ModuleType: 1abcdefghijklm

36 module = importlib.import_module(f"docs_src.tutorial.select.{request.param}") 1abcdefghijklm

37 module.engine = database_engine 1abcdefghijklm

38 return module 1abcdefghijklm

39 

40 

41@pytest.mark.parametrize( 1abcdefghijklm

42 "module", 

43 [ 

44 pytest.param("tutorial003"), 

45 ], 

46 indirect=True, 

47) 

48def test_tutorial_003(print_mock: PrintMock, module: ModuleType): 1abcdefghijklm

49 module.main() 1nprtvxzBDFHJL

50 check_calls(print_mock.calls) 1nprtvxzBDFHJL

51 

52 

53@pytest.mark.parametrize( 1abcdefghijklm

54 "module", 

55 [ 

56 pytest.param("tutorial004"), 

57 ], 

58 indirect=True, 

59) 

60def test_tutorial_004(print_mock: PrintMock, module: ModuleType): 1abcdefghijklm

61 module.main() 1oqsuwyACEGIKM

62 check_calls(print_mock.calls) 1oqsuwyACEGIKM