Skip to content

Add Lean Python unit tests CI workflow#142

Merged
jhonabreul merged 4 commits into
QuantConnect:masterfrom
jhonabreul:feature-lean-python-unit-tests
Jul 16, 2026
Merged

Add Lean Python unit tests CI workflow#142
jhonabreul merged 4 commits into
QuantConnect:masterfrom
jhonabreul:feature-lean-python-unit-tests

Conversation

@jhonabreul

Copy link
Copy Markdown
Collaborator

Description

Adds a new CI workflow (Lean Python Unit Tests) that validates Python.Runtime.dll changes against Lean's Python unit tests:

  • The Python/Pandas unit test suites (QuantConnect.Tests.Python: PandasConverterTests, PythonPackagesTests, etc.).
  • Every other Lean unit test class that runs Python code (e.g. algorithm/framework tests with Language.Python test cases, exception interpreter tests, wrapper model tests, ...).

How it works

Mirrors the existing Lean Python Regression Tests workflow: builds this repo's Python.Runtime.dll inside quantconnect/lean:foundation, builds Lean, and drops the freshly built DLL over Lean's test output.

Test selection is generated at run time: Lean's test sources are scanned for Python interop usage (Py.GIL, PythonEngine, PyObject, Language.Python, ...) and each matching file's classes become FullyQualifiedName~<Namespace>.<Class> entries in a TestCaseFilter (currently ~368 class filters), passed via a runsettings file since the expression is too long for a command line. This keeps the selection in sync with Lean automatically as tests are added or moved.

Exclusions mirror Lean's own unit test CI (TestCategory!=TravisExclude, TestCategory!=ResearchRegressionTests) plus TestCategory!=RegressionTests, since Python regression algorithms are already covered by the Lean Python Regression Tests workflow.

Runs Lean's Python/Pandas unit test suites plus every other Lean unit
test class that exercises Python code against the freshly built
Python.Runtime.dll. Test classes are selected by scanning Lean's test
sources for Python interop usage and passing the resulting
FullyQualifiedName filter through a runsettings file. Regression suites
are excluded since Python regression algorithms are already covered by
the Lean Python Regression Tests workflow.
Follow the pattern of Lean's own unit test CI job and this repo's main
workflow: run directly in a quantconnect/lean:foundation container on a
self-hosted runner instead of manually managing a docker container on a
GitHub-hosted runner.
Container jobs default to sh, which does not support the here-string
used when writing the runsettings file.
Follow the pattern of Lean's own regression tests CI job: run directly
in a quantconnect/lean:foundation container on a self-hosted runner
instead of manually managing a docker container on a GitHub-hosted
runner.
@jhonabreul
jhonabreul merged commit c080337 into QuantConnect:master Jul 16, 2026
9 checks passed
@jhonabreul
jhonabreul deleted the feature-lean-python-unit-tests branch July 16, 2026 15:50
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.

2 participants