Coverage for tests/test_tutorial/test_many_to_many/test_tutorial002_py310.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 1idefgh
3from sqlmodel import create_engine 1idefgh
5from ...conftest import get_testing_print_function, needs_py310 1idefgh
7expected_calls = [ 1defgh
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 [
36 "Updated Spider-Boy's Teams:",
37 [
38 {"id": 2, "name": "Preventers", "headquarters": "Sharp Tower"},
39 {"id": 1, "name": "Z-Force", "headquarters": "Sister Margaret's Bar"},
40 ],
41 ],
42 [
43 "Z-Force heroes:",
44 [
45 {"id": 1, "secret_name": "Dive Wilson", "age": None, "name": "Deadpond"},
46 {
47 "id": 3,
48 "secret_name": "Pedro Parqueador",
49 "age": None,
50 "name": "Spider-Boy",
51 },
52 ],
53 ],
54 [
55 "Reverted Z-Force's heroes:",
56 [{"id": 1, "secret_name": "Dive Wilson", "age": None, "name": "Deadpond"}],
57 ],
58 [
59 "Reverted Spider-Boy's teams:",
60 [{"id": 2, "name": "Preventers", "headquarters": "Sharp Tower"}],
61 ],
62]
65@needs_py310 1idefgh
66def test_tutorial(clear_sqlmodel): 1defgh
67 from docs_src.tutorial.many_to_many import tutorial002_py310 as mod 1abc
69 mod.sqlite_url = "sqlite://" 1abc
70 mod.engine = create_engine(mod.sqlite_url) 1abc
71 calls = [] 1abc
73 new_print = get_testing_print_function(calls) 1abc
75 with patch("builtins.print", new=new_print): 1abc
76 mod.main() 1abc
77 assert calls == expected_calls 1abc