fix: multiple options cli argument now overrides the default value

Problem

Auto-generated pytest plugins with option_accept_multiple=True used argparse's action="append" to collect multiple values. However, append adds user-supplied values on top of the option's default list rather than replacing it.

This meant that any option with a non-empty default (e.g. --category defaulting to ["default"]) could never be fully overridden by the user. Passing --category foo would result in ["default", "foo"] instead of the expected ["foo"], making it impossible to exclude certain default categories.

Solution

Introduce a custom argparse action AppendOverrideDefault (extending argparse._AppendAction) that:

  1. Clears the namespace value back to an empty list on the first user invocation (i.e. the first time the option is provided on the command line).
  2. Then delegates to the standard append logic for all subsequent values.

A minor cleanup is also included: the fixture method is renamed from infra_provider to _fixture (a private name) to better reflect its internal role.

Testing

Before fix — passing --category foo silently retained default category:

uv run sylva-test-framework run -- --collect-only --category foo
# collected 1 item (default category test still selected — foo had no effect alone)

After fix--category foo replaces the default completely:

uv run sylva-test-framework run -- --collect-only --category foo
# 0 tests collected (no "foo"-marked tests exist — default is correctly excluded)

uv run sylva-test-framework run -- --collect-only --category default
# 1 test collected (explicitly selecting the default category still works)

uv run sylva-test-framework run -- --collect-only
# 1 test collected (omitting the flag preserves the default behaviour)
Edited by Jonathan GAYVALLET

Merge request reports

Loading