File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change
1
+ from typing import List
2
+
1
3
import lib
4
+ import pytest_mock
5
+ # noinspection PyUnresolvedReferences
2
6
from test_fixtures import guitar_data
3
7
4
8
@@ -13,8 +17,23 @@ def test_something():
13
17
# assert all(g.style == style for g in guitars)
14
18
15
19
16
- def test_electric_guitars (guitar_data ):
20
+ def test_electric_guitars (guitar_data : List [lib .Guitar ], mocker : pytest_mock .MockFixture ):
21
+ mocker .patch ('lib.get_guitars_from_db' , autospec = True , return_value = guitar_data )
22
+ mocker .patch ('lib.log' , autospec = True )
23
+
17
24
style = 'electric'
18
25
guitars = lib .all_guitars (style )
19
26
# sweet little generator expression
20
27
assert all (g .style == style for g in guitars )
28
+
29
+
30
+ def test_all_guitars (guitar_data : List [lib .Guitar ], mocker : pytest_mock .MockFixture ):
31
+ mocker .patch ('lib.get_guitars_from_db' , autospec = True , return_value = guitar_data )
32
+ mocker .patch ('lib.log' , autospec = True )
33
+
34
+ style = 'all'
35
+ guitars = lib .all_guitars (style )
36
+ # sweet little generator expression
37
+ types = {g .style for g in guitars }
38
+
39
+ assert types == {'acoustic' , 'electric' }
You can’t perform that action at this time.
0 commit comments