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

12 statements  

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

1from unittest.mock import patch 1ghijkl

2 

3from sqlmodel import create_engine 1ghijkl

4 

5from ...conftest import get_testing_print_function 1ghijkl

6 

7 

8def test_tutorial(clear_sqlmodel): 1ghijkl

9 from docs_src.tutorial.where import tutorial002 as mod 1abcdef

10 

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

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

13 calls = [] 1abcdef

14 

15 new_print = get_testing_print_function(calls) 1abcdef

16 

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

18 mod.main() 1abcdef

19 assert calls == [ 1abcdef

20 [ 

21 { 

22 "name": "Spider-Boy", 

23 "secret_name": "Pedro Parqueador", 

24 "age": None, 

25 "id": 2, 

26 } 

27 ], 

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

29 ]