session: add plugins args from JSON in reverse

This commit is contained in:
bastimeyer 2024-02-17 04:18:55 +01:00 committed by Sebastian Meyer
parent 5e0e38afc2
commit bf4ff71003
2 changed files with 11 additions and 9 deletions

View File

@ -317,7 +317,7 @@ class StreamlinkPluginsData:
if not plugindata.get("arguments"):
continue
arguments = Arguments()
for a in plugindata.get("arguments") or []:
for a in reversed(plugindata.get("arguments") or []):
if argument := cls._build_argument(a):
arguments.add(argument)

View File

@ -387,7 +387,13 @@ class TestLoadPluginsData:
assert session.plugins.get_names() == ["empty", "testpluginA", "testpluginB"]
assert [(record.name, record.levelname, record.message) for record in caplog.get_records(when="setup")] == []
# arguments are added in reverse order:
# `Arguments` does this because of the reverse order of the @pluginargument decorator
arguments_a = Arguments()
arguments_a.add(Argument(
name="bar",
const="bar",
))
arguments_a.add(Argument(
name="foo",
action="store",
@ -400,19 +406,15 @@ class TestLoadPluginsData:
dest="oof",
argument_name="oof",
))
arguments_a.add(Argument(
name="bar",
const="bar",
))
arguments_b = Arguments()
arguments_b.add(Argument(
name="bool",
type=boolean,
))
arguments_b.add(Argument(
name="cmf",
type=comma_list_filter(["1", "2", "3"], unique=True),
))
arguments_b.add(Argument(
name="bool",
type=boolean,
))
assert list(session.plugins.iter_arguments()) == [("testpluginA", arguments_a), ("testpluginB", arguments_b)]
@pytest.mark.parametrize("pluginsdata", [