Coverage for tests/test_tutorial/test_limit_and_offset/test_tutorial002.py: 100%

14 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

3 

4import pytest 1abcdefghijklm

5from sqlalchemy import Engine 1abcdefghijklm

6 

7from ...conftest import PrintMock 1abcdefghijklm

8 

9 

10@pytest.fixture( 1abcdefghijklm

11 name="mod", 

12 params=[ 

13 pytest.param("tutorial002"), 

14 ], 

15) 

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

17 mod = importlib.import_module(f"docs_src.tutorial.offset_and_limit.{request.param}") 1abcdefghijklm

18 mod.engine = database_engine 1abcdefghijklm

19 return mod 1abcdefghijklm

20 

21 

22expected_calls = [ 1abcdefghijklm

23 [ 

24 [ 

25 { 

26 "id": 4, 

27 "name": "Tarantula", 

28 "secret_name": "Natalia Roman-on", 

29 "age": 32, 

30 }, 

31 {"id": 5, "name": "Black Lion", "secret_name": "Trevor Challa", "age": 35}, 

32 {"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36}, 

33 ] 

34 ] 

35] 

36 

37 

38def test_tutorial(print_mock: PrintMock, mod: ModuleType): 1abcdefghijklm

39 mod.main() 1nopqrstuvwxyz

40 assert print_mock.calls == expected_calls 1nopqrstuvwxyz