Coverage for tests/test_advanced/test_decimal/test_tutorial001_py310.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-09 00:02 +0000

1from decimal import Decimal 1idefgh

2from unittest.mock import patch 1idefgh

3 

4from sqlmodel import create_engine 1idefgh

5 

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

7 

8expected_calls = [ 1defgh

9 [ 

10 "Hero 1:", 

11 { 

12 "name": "Deadpond", 

13 "age": None, 

14 "id": 1, 

15 "secret_name": "Dive Wilson", 

16 "money": Decimal("1.100"), 

17 }, 

18 ], 

19 [ 

20 "Hero 2:", 

21 { 

22 "name": "Rusty-Man", 

23 "age": 48, 

24 "id": 3, 

25 "secret_name": "Tommy Sharp", 

26 "money": Decimal("2.200"), 

27 }, 

28 ], 

29 ["Total money: 3.300"], 

30] 

31 

32 

33@needs_py310 1idefgh

34def test_tutorial(clear_sqlmodel): 1defgh

35 from docs_src.advanced.decimal import tutorial001_py310 as mod 1abc

36 

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

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

39 calls = [] 1abc

40 

41 new_print = get_testing_print_function(calls) 1abc

42 

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

44 mod.main() 1abc

45 assert calls == expected_calls 1abc