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

14 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-27 00:03 +0000

1from unittest.mock import patch 1ijklmnopqr

2 

3from sqlmodel import create_engine 1ijklmnopqr

4 

5from ...conftest import get_testing_print_function, needs_py310 1ijklmnopqr

6 

7expected_calls = [ 1ijklmnopqr

8 [ 

9 [ 

10 {"id": 1, "name": "Deadpond", "secret_name": "Dive Wilson", "age": None}, 

11 { 

12 "id": 2, 

13 "name": "Spider-Boy", 

14 "secret_name": "Pedro Parqueador", 

15 "age": None, 

16 }, 

17 {"id": 3, "name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48}, 

18 ] 

19 ] 

20] 

21 

22 

23@needs_py310 1ijklmnopqr

24def test_tutorial(clear_sqlmodel): 1ijklmnopqr

25 from docs_src.tutorial.offset_and_limit import tutorial001_py310 as mod 1abcdefgh

26 

27 mod.sqlite_url = "sqlite://" 1abcdefgh

28 mod.engine = create_engine(mod.sqlite_url) 1abcdefgh

29 calls = [] 1abcdefgh

30 

31 new_print = get_testing_print_function(calls) 1abcdefgh

32 

33 with patch("builtins.print", new=new_print): 1abcdefgh

34 mod.main() 1abcdefgh

35 assert calls == expected_calls 1abcdefgh