conftest.py 605 B

12345678910111213141516171819202122
  1. import functools
  2. import inspect
  3. import pytest
  4. from hypervideo_dl.networking import RequestHandler
  5. from hypervideo_dl.networking.common import _REQUEST_HANDLERS
  6. from hypervideo_dl.utils._utils import _YDLLogger as FakeLogger
  7. @pytest.fixture
  8. def handler(request):
  9. RH_KEY = request.param
  10. if inspect.isclass(RH_KEY) and issubclass(RH_KEY, RequestHandler):
  11. handler = RH_KEY
  12. elif RH_KEY in _REQUEST_HANDLERS:
  13. handler = _REQUEST_HANDLERS[RH_KEY]
  14. else:
  15. pytest.skip(f'{RH_KEY} request handler is not available')
  16. return functools.partial(handler, logger=FakeLogger)