Skip to content

python: make the feature's test harness build, link and run (ibx#381) - #393

Open
userFRM wants to merge 1 commit into
deepentropy:mainfrom
userFRM:fix/python-test-harness
Open

python: make the feature's test harness build, link and run (ibx#381)#393
userFRM wants to merge 1 commit into
deepentropy:mainfrom
userFRM:fix/python-test-harness

Conversation

@userFRM

@userFRM userFRM commented Jul 31, 2026

Copy link
Copy Markdown

Problem

No Rust-side test under the python feature had ever run. The harness failed in two stages, and cargo check --lib --features python passes, which is why neither was visible.

It did not compile. A test called EWrapper::new() with no arguments; the PyO3 constructor takes the tuple and dict it is handed from Python, so that call had been wrong since the signature was introduced.

It then did not link. extension-module tells PyO3 not to link libpython — correct for the wheel, wrong for a test binary. Every Python symbol came back undefined.

What this changes

The feature is split: the wheel asks for python,extension-module (set in pyproject.toml), a test build asks only for python.

Linking is not enough on its own — the loader has to find the library at run time. A build script emits the interpreter's own library directory as an rpath, and only for a build that is not the extension module, so the wheel is untouched. cargo test --features python now needs nothing set up around it.

Two tests were waiting to run, and did not pass

contract_default_values asserted ibapi's empty contract defaults, while this crate presents STK, SMART and USD — the values its own #[new] signature declares. Corrected to the defaults the code actually has.

The stale wrapper test is replaced by one asserting what the type presents to a subclass: the callback methods a consumer overrides. That the type is constructible is what the compiler already checks.

Result

cargo test --offline --lib --features python818 passed, with only the two known config::expiry_tests tzdata failures. Previously that command did not produce a binary at all.

Verified that the wheel configuration (--features python,extension-module) still builds the cdylib, and that a default build is unaffected.

Closes #381.

No Rust-side test under the `python` feature had ever run. The harness failed in two stages, and `cargo check --lib --features python` passes, which is why neither was visible.

It did not compile: a test called `EWrapper::new()` with no arguments, and the PyO3 constructor takes the tuple and dict it is handed from Python, so that call had been wrong since the signature was introduced.

It then did not link. `extension-module` tells PyO3 not to link libpython, which is correct for the wheel and wrong for a test binary — every Python symbol came back undefined. The feature is split so the wheel asks for both and a test build asks only for `python`; `pyproject.toml` passes the pair.

Linking is not enough on its own: the loader has to find the library at run time. A build script emits the interpreter's own library directory as an rpath, and only for a build that is not the extension module, so the wheel is untouched. `cargo test --features python` now needs no environment set up around it.

Two tests were waiting to run and did not pass.

`contract_default_values` asserted ibapi's empty contract defaults, while this crate presents `STK`, `SMART` and `USD` — the values its own constructor signature declares. The test is corrected to the defaults the code actually has.

The stale wrapper test is replaced by one that asserts what the type presents to a subclass, which is the thing worth pinning: the callback methods a consumer overrides. That the type is constructible is what the compiler already checks.

Closes deepentropy#381.
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.

python: no Rust-side unit test under the python feature has ever run — the harness does not compile, then does not link

1 participant