aboutsummaryrefslogtreecommitdiffstats
path: root/test/conftest.py
blob: 48d928805247ef363e82c4b219d0f69761efd77e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import functools
import inspect

import pytest

from hypervideo_dl.networking import RequestHandler
from hypervideo_dl.networking.common import _REQUEST_HANDLERS
from hypervideo_dl.utils._utils import _YDLLogger as FakeLogger


@pytest.fixture
def handler(request):
    RH_KEY = request.param
    if inspect.isclass(RH_KEY) and issubclass(RH_KEY, RequestHandler):
        handler = RH_KEY
    elif RH_KEY in _REQUEST_HANDLERS:
        handler = _REQUEST_HANDLERS[RH_KEY]
    else:
        pytest.skip(f'{RH_KEY} request handler is not available')

    return functools.partial(handler, logger=FakeLogger)