Coverage for tests/test_tutorial/test_where/test_tutorial002_py310.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 1idefgh

2 

3from sqlmodel import create_engine 1idefgh

4 

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

6 

7 

8@needs_py310 1idefgh

9def test_tutorial(clear_sqlmodel): 1defgh

10 from docs_src.tutorial.where import tutorial002_py310 as mod 1abc

11 

12 mod.sqlite_url = "sqlite://" 1abc

13 mod.engine = create_engine(mod.sqlite_url) 1abc

14 calls = [] 1abc

15 

16 new_print = get_testing_print_function(calls) 1abc

17 

18 with patch("builtins.print", new=new_print): 1abc

19 mod.main() 1abc

20 assert calls == [ 1abc

21 [ 

22 { 

23 "name": "Spider-Boy", 

24 "secret_name": "Pedro Parqueador", 

25 "age": None, 

26 "id": 2, 

27 } 

28 ], 

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

30 ]