Skip to content

feat: add parametrized test expansion support#73

Open
ronald-braunstein wants to merge 3 commits intohughhan1:mainfrom
ronald-braunstein:params
Open

feat: add parametrized test expansion support#73
ronald-braunstein wants to merge 3 commits intohughhan1:mainfrom
ronald-braunstein:params

Conversation

@ronald-braunstein
Copy link
Copy Markdown

Implement full expansion of @pytest.mark.parametrize decorators during test collection to match pytest's behavior. This resolves the known limitation documented in the README where rtest only collected base function names.

Changes:

  • Parse pytest.mark.parametrize decorators from function AST
  • Extract parameter names and values from decorator arguments
  • Generate all parameter combinations for stacked decorators
  • Support for simple params, multiple params, and cartesian products
  • Handle various Python literal types (int, float, string, bool, None, etc.)
  • Works for both module-level functions and class methods
  • Compatible with test class inheritance

Test expansion now matches pytest exactly:
test_example[1] test_example[2] test_example[3]

Previously showed only: test_example

🤖 Generated with Claude Code

ronald-braunstein and others added 3 commits October 8, 2025 21:43
Implement full expansion of @pytest.mark.parametrize decorators during test
collection to match pytest's behavior. This resolves the known limitation
documented in the README where rtest only collected base function names.

Changes:
- Parse pytest.mark.parametrize decorators from function AST
- Extract parameter names and values from decorator arguments
- Generate all parameter combinations for stacked decorators
- Support for simple params, multiple params, and cartesian products
- Handle various Python literal types (int, float, string, bool, None, etc.)
- Works for both module-level functions and class methods
- Compatible with test class inheritance

Test expansion now matches pytest exactly:
  test_example[1]
  test_example[2]
  test_example[3]

Previously showed only: test_example

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ection

- Add ParamValue::AttributeAccess variant to mark attribute access expressions as uncertain
- Add has_uncertain_params field to TestInfo, TestMethodInfo, and Function structs
- Mark files as uncertain when parametrize values contain:
  - Attribute accesses (Enum.VALUE, Class.CONSTANT)
  - Function calls (Decimal("1"), func())
  - Complex expressions (tuples, lists, dicts)
  - Strings with special characters (newlines, tabs, non-ASCII)
- Update collection_integration to use has_uncertain_params() for uncertainty detection
- Add --emit-uncertain-files flag to output list of uncertain files
- Add --all-parametrized-uncertain flag to mark ALL parametrized files as uncertain

Results:
- Hybrid WITH flag: 4.0x faster (100% accurate)
- Hybrid WITHOUT flag: 4.7x faster (99.76% accurate, 66 edge case tests)
- Native rtest: 24.1x faster

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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