1
mirror of https://github.com/streamlink/streamlink synced 2024-09-28 13:05:55 +02:00

session: turn session module into a sub-package

- Create `streamlink.session` sub-package and move `session` module
  - Update/fix logger name
- Create `tests.session` sub-package and move `test_session` module
  - Fix monkeypatch paths
- Run session tests with a higher priority
This commit is contained in:
bastimeyer 2024-01-31 20:43:43 +01:00 committed by Sebastian Meyer
parent 5ce6cc7a77
commit 282098a76a
5 changed files with 7 additions and 5 deletions

View File

@ -0,0 +1 @@
from streamlink.session.session import Streamlink

View File

@ -21,7 +21,7 @@ from streamlink.utils.url import update_scheme
# Ensure that the Logger class returned is Streamslink's for using the API (for backwards compatibility)
logging.setLoggerClass(StreamlinkLogger)
log = logging.getLogger(__name__)
log = logging.getLogger(".".join(__name__.split(".")[:-1]))
_original_allowed_gai_family = urllib3_util_connection.allowed_gai_family # type: ignore[attr-defined]

View File

@ -18,6 +18,7 @@ _TEST_PRIORITIES = (
"build_backend/",
"tests/testutils/",
"tests/utils/",
"tests/session/",
None,
"tests/stream/",
"tests/test_plugins.py",

View File

View File

@ -102,8 +102,8 @@ class TestLoadPlugins:
raises: nullcontext,
logs: list,
):
monkeypatch.setattr("streamlink.session.Streamlink.load_builtin_plugins", Mock())
monkeypatch.setattr("streamlink.session.exec_module", Mock(side_effect=side_effect))
monkeypatch.setattr("streamlink.session.session.Streamlink.load_builtin_plugins", Mock())
monkeypatch.setattr("streamlink.session.session.exec_module", Mock(side_effect=side_effect))
session = Streamlink()
with raises:
session.load_plugins(str(PATH_TESTPLUGINS))
@ -349,7 +349,7 @@ class TestOptionsInterface:
scheme: Mock(poolmanager=Mock(connection_pool_kw={}))
for scheme in ("http://", "https://", "foo://")
}
monkeypatch.setattr("streamlink.session.HTTPSession", Mock(return_value=Mock(adapters=adapters)))
monkeypatch.setattr("streamlink.session.session.HTTPSession", Mock(return_value=Mock(adapters=adapters)))
return adapters
@ -374,7 +374,7 @@ class TestOptionsInterface:
def test_options_ipv4_ipv6(monkeypatch: pytest.MonkeyPatch, session: Streamlink):
mock_urllib3_util_connection = Mock(allowed_gai_family=_original_allowed_gai_family)
monkeypatch.setattr("streamlink.session.urllib3_util_connection", mock_urllib3_util_connection)
monkeypatch.setattr("streamlink.session.session.urllib3_util_connection", mock_urllib3_util_connection)
assert session.get_option("ipv4") is False
assert session.get_option("ipv6") is False