Coverage for tests/test_tutorial/test_where/test_tutorial011.py: 100%
16 statements
« prev ^ index » next coverage.py v7.7.1, created at 2025-03-24 00:02 +0000
« prev ^ index » next coverage.py v7.7.1, created at 2025-03-24 00:02 +0000
1from unittest.mock import patch 1ghijkl
3from sqlmodel import create_engine 1ghijkl
5from ...conftest import get_testing_print_function 1ghijkl
8def test_tutorial(clear_sqlmodel): 1ghijkl
9 from docs_src.tutorial.where import tutorial011 as mod 1abcdef
11 mod.sqlite_url = "sqlite://" 1abcdef
12 mod.engine = create_engine(mod.sqlite_url) 1abcdef
13 calls = [] 1abcdef
15 new_print = get_testing_print_function(calls) 1abcdef
17 with patch("builtins.print", new=new_print): 1abcdef
18 mod.main() 1abcdef
19 expected_calls = [ 1abcdef
20 [{"id": 5, "name": "Black Lion", "secret_name": "Trevor Challa", "age": 35}],
21 [{"id": 6, "name": "Dr. Weird", "secret_name": "Steve Weird", "age": 36}],
22 [{"id": 3, "name": "Rusty-Man", "secret_name": "Tommy Sharp", "age": 48}],
23 [
24 {
25 "id": 7,
26 "name": "Captain North America",
27 "secret_name": "Esteban Rogelios",
28 "age": 93,
29 }
30 ],
31 ]
32 for call in expected_calls: 1abcdef
33 assert call in calls, "This expected item should be in the list" 1abcdef
34 # Now that this item was checked, remove it from the list
35 calls.pop(calls.index(call)) 1abcdef
36 assert len(calls) == 0, "The list should only have the expected items" 1abcdef