コード例 #1
0
    def test_add_episode_success(self):
        episode1 = LostFilmEpisode(1, 1)
        episode2 = LostFilmEpisode(1, 2)

        season = LostFilmSeason(1)

        season.add_episode(episode1)
        season.add_episode(episode2)

        assert len(season) == 2

        assert season[1] == episode1
        assert season[2] == episode2

        assert list(season) == [episode1, episode2]
        assert list(reversed(season)) == [episode2, episode1]
コード例 #2
0
    def test_add_episode_failed(self):
        episode1 = LostFilmEpisode(2, 1)

        season = LostFilmSeason(2)

        season.add_episode(episode1)
        with pytest.raises(Exception) as e:
            season.add_episode(episode1)
        message = six.text_type(e.value)
        assert six.text_type(episode1.number) in message
        assert six.text_type(season.number) in message
        assert 'already' in message

        assert len(season) == 1

        assert season[1] == episode1

        assert list(season) == [episode1]
        assert list(reversed(season)) == [episode1]