Ejemplo n.º 1
0
class TestCLIMainHandleUrl:
    @pytest.mark.parametrize("side_effect,expected", [
        (NoPluginError("foo"), "No plugin can handle URL: fakeurl"),
        (PluginError("bar"), "bar"),
    ])
    def test_error(self, side_effect, expected):
        with patch("streamlink_cli.main.args", Mock(url="fakeurl")), \
             patch("streamlink_cli.main.streamlink", resolve_url=Mock(side_effect=side_effect)), \
             patch("streamlink_cli.main.console", exit=Mock(side_effect=SystemExit)) as mock_console:
            with pytest.raises(SystemExit):
                handle_url()
            assert mock_console.exit.mock_calls == [call(expected)]
Ejemplo n.º 2
0
 def resolve_url(name):
     if name == "noplugin":
         raise NoPluginError()
     return Mock(module="testplugin")