session: fix http-trust-env option

This commit is contained in:
bastimeyer 2023-02-23 22:06:26 +01:00 committed by Sebastian Meyer
parent 77e67a7002
commit 2a24f314f2
2 changed files with 28 additions and 10 deletions

View File

@ -32,16 +32,6 @@ class PythonDeprecatedWarning(UserWarning):
class StreamlinkOptions(Options):
_OPTIONS_HTTP_ATTRS = {
"http-cookies": "cookies",
"http-headers": "headers",
"http-query-params": "params",
"http-ssl-cert": "cert",
"http-ssl-trust-env": "trust_env",
"http-ssl-verify": "verify",
"http-timeout": "timeout",
}
def __init__(self, session: "Streamlink", *args, **kwargs):
super().__init__(*args, **kwargs)
self.session = session
@ -144,6 +134,16 @@ class StreamlinkOptions(Options):
# ----
_OPTIONS_HTTP_ATTRS = {
"http-cookies": "cookies",
"http-headers": "headers",
"http-query-params": "params",
"http-ssl-cert": "cert",
"http-ssl-verify": "verify",
"http-trust-env": "trust_env",
"http-timeout": "timeout",
}
_MAP_GETTERS: ClassVar[Mapping[str, Callable[["StreamlinkOptions", str], Any]]] = {
"http-proxy": _get_http_proxy,
"https-proxy": _get_http_proxy,

View File

@ -525,6 +525,24 @@ class TestOptionsKeyEqualsValue:
session.set_option(option, value)
@pytest.mark.parametrize(
("option", "attr", "default", "value"),
[
("http-ssl-cert", "cert", None, "foo"),
("http-ssl-verify", "verify", True, False),
("http-trust-env", "trust_env", True, False),
("http-timeout", "timeout", 20.0, 30.0),
],
)
def test_options_http_other(session: Streamlink, option: str, attr: str, default, value):
httpsessionattr = getattr(session.http, attr)
assert httpsessionattr == default
assert session.get_option(option) == httpsessionattr
session.set_option(option, value)
assert session.get_option(option) == value
class TestOptionsDocumentation:
@pytest.fixture()
def docstring(self, session: Streamlink):