Release 2023.12.30
[yt-dlp.git] / test / conftest.py
blob2fbc269e1fb7b4b509a83115d1a5a1ad890033f7
1 import functools
2 import inspect
4 import pytest
6 from yt_dlp.networking import RequestHandler
7 from yt_dlp.networking.common import _REQUEST_HANDLERS
8 from yt_dlp.utils._utils import _YDLLogger as FakeLogger
11 @pytest.fixture
12 def handler(request):
13 RH_KEY = request.param
14 if inspect.isclass(RH_KEY) and issubclass(RH_KEY, RequestHandler):
15 handler = RH_KEY
16 elif RH_KEY in _REQUEST_HANDLERS:
17 handler = _REQUEST_HANDLERS[RH_KEY]
18 else:
19 pytest.skip(f'{RH_KEY} request handler is not available')
21 return functools.partial(handler, logger=FakeLogger)
24 def validate_and_send(rh, req):
25 rh.validate(req)
26 return rh.send(req)