@@ -911,7 +911,7 @@ Create ``tests.py`` in the ``movies`` package:
911
911
and put next into it:
912
912
913
913
.. code-block :: python
914
- :emphasize- lines: 36 , 51
914
+ :emphasize- lines: 41 , 50
915
915
916
916
""" Tests module."""
917
917
@@ -941,13 +941,18 @@ and put next into it:
941
941
return container
942
942
943
943
944
- def test_movies_directed_by (container ):
944
+ @pytest.fixture
945
+ def finder_mock (container ):
945
946
finder_mock = mock.Mock()
946
947
finder_mock.find_all.return_value = [
947
948
container.movie(" The 33" , 2015 , " Patricia Riggen" ),
948
949
container.movie(" The Jungle Book" , 2016 , " Jon Favreau" ),
949
950
]
950
951
952
+ return finder_mock
953
+
954
+
955
+ def test_movies_directed_by (container , finder_mock ):
951
956
with container.finder.override(finder_mock):
952
957
lister = container.lister()
953
958
movies = lister.movies_directed_by(" Jon Favreau" )
@@ -956,13 +961,7 @@ and put next into it:
956
961
assert movies[0 ].title == " The Jungle Book"
957
962
958
963
959
- def test_movies_released_in (container ):
960
- finder_mock = mock.Mock()
961
- finder_mock.find_all.return_value = [
962
- container.movie(" The 33" , 2015 , " Patricia Riggen" ),
963
- container.movie(" The Jungle Book" , 2016 , " Jon Favreau" ),
964
- ]
965
-
964
+ def test_movies_released_in (container , finder_mock ):
966
965
with container.finder.override(finder_mock):
967
966
lister = container.lister()
968
967
movies = lister.movies_released_in(2015 )
@@ -995,9 +994,9 @@ You should see:
995
994
movies/entities.py 7 1 86%
996
995
movies/finders.py 26 13 50%
997
996
movies/listers.py 8 0 100%
998
- movies/tests.py 23 0 100%
997
+ movies/tests.py 24 0 100%
999
998
------------------------------------------
1000
- TOTAL 89 30 66 %
999
+ TOTAL 90 30 67 %
1001
1000
1002
1001
.. note ::
1003
1002
0 commit comments