Coverage for tests/test_tutorial/test_many_to_many/test_tutorial001_py39.py: 100%
14 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 1jefghi
3from sqlmodel import create_engine 1jefghi
5from ...conftest import get_testing_print_function, needs_py39 1jefghi
7expected_calls = [ 1efghi
8 [
9 "Deadpond:",
10 {"id": 1, "secret_name": "Dive Wilson", "age": None, "name": "Deadpond"},
11 ],
12 [
13 "Deadpond teams:",
14 [
15 {"id": 1, "name": "Z-Force", "headquarters": "Sister Margaret's Bar"},
16 {"id": 2, "name": "Preventers", "headquarters": "Sharp Tower"},
17 ],
18 ],
19 [
20 "Rusty-Man:",
21 {"id": 2, "secret_name": "Tommy Sharp", "age": 48, "name": "Rusty-Man"},
22 ],
23 [
24 "Rusty-Man Teams:",
25 [{"id": 2, "name": "Preventers", "headquarters": "Sharp Tower"}],
26 ],
27 [
28 "Spider-Boy:",
29 {"id": 3, "secret_name": "Pedro Parqueador", "age": None, "name": "Spider-Boy"},
30 ],
31 [
32 "Spider-Boy Teams:",
33 [{"id": 2, "name": "Preventers", "headquarters": "Sharp Tower"}],
34 ],
35]
38@needs_py39 1jefghi
39def test_tutorial(clear_sqlmodel): 1efghi
40 from docs_src.tutorial.many_to_many import tutorial001_py39 as mod 1abcd
42 mod.sqlite_url = "sqlite://" 1abcd
43 mod.engine = create_engine(mod.sqlite_url) 1abcd
44 calls = [] 1abcd
46 new_print = get_testing_print_function(calls) 1abcd
48 with patch("builtins.print", new=new_print): 1abcd
49 mod.main() 1abcd
50 assert calls == expected_calls 1abcd