Skip to content

Conversation

@MarkKoz
Copy link

@MarkKoz MarkKoz commented Jan 1, 2026

@niftools/pyffi-reviewer

Overview

The test suite had various problems. I wasn't able to run it on Python 3.14. The first order of business was to replace the unmaintained nose package with pytest. In this process, I caught some tests that were written incorrectly.

Doctests were running, but the results were not being checked or reported. I removed the custom doctest runner in favour of the pytest-doctestplus plugin. One thing we lose is the ability to assert log messages in doctest. There were only a handful of tests that relied on this, and I don't think too much value was lost from those tests. Moving forward, we should write tests in pytest if we need to assert logs.

I discovered several failing doctests. Some were due to bugs I was able to fix. Others I could not fix, and ended up disabling. My understanding is these tests have been broken for a long time, and were not caught because of incorrectly running the doctests.

Fixes Known Issues

None.

Documentation

Updated instructions in README for running tests.

Testing

Ran the full test suite.

Manual

None

Automated

Full test suite executed with pytest.

Additional Information

Bumped minimum Python version to 3.10. Anything lower is end of life.

Nose seems to be broken with modern Python versions.
nose-py3 may have worked, but may as well move to pytest at this point.
Expressions like "ARG / 3" are evaluated using Python's "/" operator.
This is normal division, not floored division, so it may return a float.
Not sure if the warning is expected
I incorrectly treated nose's assert_true with two arguments as an
equality assertion when converting to pytest. Turns out this test just
made no sense to begin with.
The amount of children is still 4 because the nodes are set to None
rather than removed from the children array.

This wasn't caught before because the original test used
assert_true(len(children), 2). The second argument is a custom message
to show when the assertion fails. The intention was likely assert_equal.
Previously we had a customer runner for doctests which had some setup
for exposing log messages to doctest. Now that we run them through
pytest, the logs cannot be asserted in doctests. Need to figure out
a way to expose logs again.
I don't know how to fix these right now. The CGF one is particularly
confusing since it seems like the ELLIPSIS option for doctest isn't
working only for that test.
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