Skip to content

[ENH] Add test to validate execution of README Python examples#713

Open
PredictiveManish wants to merge 3 commits intoPyPortfolio:mainfrom
PredictiveManish:Test-README
Open

[ENH] Add test to validate execution of README Python examples#713
PredictiveManish wants to merge 3 commits intoPyPortfolio:mainfrom
PredictiveManish:Test-README

Conversation

@PredictiveManish
Copy link

Adds a pytest that parses README.md and executes all python code blocks to ensure examples remain valid.

Closes #669

  • Uses regex to extract Python blocks
  • Executes them sequentially in a shared namespace (since examples are stateful)
  • Runs from repo root so relative paths like tests/resources/... resolve correctly
  • Adds repo root to sys.path so pypfopt can be imported without installation

This verifies that README examples run as documented and helps prevent regressions in imports or usage.

@fkiraly fkiraly added the enhancement New feature or request label Feb 27, 2026
@PredictiveManish
Copy link
Author

PredictiveManish commented Feb 27, 2026

The extra file changes occurred when I started working on the CI failure issue, as Ruff auto-formatting modified some files.

and as it's not any logic break or any particular change so I added them here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] add tests for correctness of code in README

2 participants