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

13 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 00:02 +0000

1from unittest.mock import patch 1lghijk

2 

3from sqlmodel import create_engine 1lghijk

4 

5from ...conftest import get_testing_print_function 1lghijk

6 

7expected_calls = [ 1ghijk

8 [ 

9 [ 

10 { 

11 "id": 7, 

12 "name": "Captain North America", 

13 "secret_name": "Esteban Rogelios", 

14 "age": 93, 

15 } 

16 ] 

17 ] 

18] 

19 

20 

21def test_tutorial(clear_sqlmodel): 1lghijk

22 from docs_src.tutorial.offset_and_limit import tutorial003 as mod 1abcdef

23 

24 mod.sqlite_url = "sqlite://" 1abcdef

25 mod.engine = create_engine(mod.sqlite_url) 1abcdef

26 calls = [] 1abcdef

27 

28 new_print = get_testing_print_function(calls) 1abcdef

29 

30 with patch("builtins.print", new=new_print): 1abcdef

31 mod.main() 1abcdef

32 assert calls == expected_calls 1abcdef