@@ -911,7 +911,7 @@ Create ``tests.py`` in the ``movies`` package:
911911 and put next into it:
912912
913913.. code-block :: python
914- :emphasize- lines: 36 , 51
914+ :emphasize- lines: 41 , 50
915915
916916 """ Tests module."""
917917
@@ -941,13 +941,18 @@ and put next into it:
941941 return container
942942
943943
944- def test_movies_directed_by (container ):
944+ @pytest.fixture
945+ def finder_mock (container ):
945946 finder_mock = mock.Mock()
946947 finder_mock.find_all.return_value = [
947948 container.movie(" The 33" , 2015 , " Patricia Riggen" ),
948949 container.movie(" The Jungle Book" , 2016 , " Jon Favreau" ),
949950 ]
950951
952+ return finder_mock
953+
954+
955+ def test_movies_directed_by (container , finder_mock ):
951956 with container.finder.override(finder_mock):
952957 lister = container.lister()
953958 movies = lister.movies_directed_by(" Jon Favreau" )
@@ -956,13 +961,7 @@ and put next into it:
956961 assert movies[0 ].title == " The Jungle Book"
957962
958963
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 ):
966965 with container.finder.override(finder_mock):
967966 lister = container.lister()
968967 movies = lister.movies_released_in(2015 )
@@ -995,9 +994,9 @@ You should see:
995994 movies/entities.py 7 1 86%
996995 movies/finders.py 26 13 50%
997996 movies/listers.py 8 0 100%
998- movies/tests.py 23 0 100%
997+ movies/tests.py 24 0 100%
999998 ------------------------------------------
1000- TOTAL 89 30 66 %
999+ TOTAL 90 30 67 %
10011000
10021001 .. note ::
10031002
0 commit comments