Skip to content

Support weights on subtests - #49

Merged
eliotwrobson merged 1 commit into
mainfrom
claude/subtest-weights
Nov 18, 2026
Merged

eliotwrobson merged 1 commit into
mainfrom
claude/subtest-weights

Conversation

@eliotwrobson

Copy link
Copy Markdown
Collaborator

subtests.test(weight=2) makes a block count twice as much toward the test's score. The default weight is 1, so existing tests score the same.

for n, weight in [(2, 1), (10, 1), (29, 2)]:
    with subtests.test(weight=weight):
        assert_fn_equal(sandbox, "fib", args=(n,), expected=fib(n))
  • The score is the weight of the passed blocks divided by the total weight. The message still counts blocks, such as 2/3 checks passed.
  • A weight of 0 still checks and shows the block. A weight that isn't a non-negative int or float, or weights that are all 0, give the test 0 points and a message saying what's wrong.
  • pytest 9.2 stores keyword arguments to subtests.test() as their repr, while 9.0 keeps the values. The plugin reads either. The subtest tests pass on both versions.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eliotwrobson
eliotwrobson marked this pull request as ready for review November 18, 2026 07:47
@eliotwrobson
eliotwrobson merged commit e6f69c1 into main Nov 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant