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