Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: Run SWIG unit tests in CI action#30161

Merged
charris merged 3 commits intonumpy:mainfrom
rlaboiss:swig-unit-tests
Nov 6, 2025
Merged

ENH: Run SWIG unit tests in CI action#30161
charris merged 3 commits intonumpy:mainfrom
rlaboiss:swig-unit-tests

Conversation

@rlaboiss
Copy link
Contributor

@rlaboiss rlaboiss commented Nov 6, 2025

This is an attempt to address issue #30131. The solution implemented follows the @rgommers' recommendation to run the Makefile in the tools/swig/test/ directory at the very end of the sdist job in the linux.yml workflow.

Besides the commit that adds the CI action commands, two other things needed to be fixed in the Python code of the files in the directory tools/swig/test/test*.py:

  • Replace the deprecated method unittest.makeSuite() with unittest.TestLoader().loadTestsFromTestCase()
  • Avoid errors due to negative values in uint8, uint16, uint32 and uint64 arrays

In my forked repository, I had to make further tweaks to the linux.yml workflow, in order to run the CI action. My changes yielded the expected results.

Closes: #30131

The unit tests involving `<type>TestCase.testMaxWrongDim` do not work for
`<type>` being one of `uchar`, `ushort`, `uint`, `ulong`, and
`ulongLong` (which translate to `uint8`, `uint16`, `uint32`, `uint64`, and
`uint64`, respectively). Instead of raising the expected `TypeError`, the
unit tests raise `OverflowError`, with the error message “Python integer -1
out of bounds for <type>”. This is fixed by replacing the negative values
in the argument of the `max` function by positive ones.
The unit tests will be run in the Linux workflow using the Makefile
distributed in `tools/swig/test` directory. They are run after installation
of NumPy in the system, ensuring that the C header files are correctly
included (see GitHub issue [numpy#30131](numpy#30131)).
@charris charris merged commit 2740d5f into numpy:main Nov 6, 2025
76 checks passed
@charris
Copy link
Member

charris commented Nov 6, 2025

Thanks @rlaboiss .

cakedev0 pushed a commit to cakedev0/numpy that referenced this pull request Dec 5, 2025
* Replace deprecated unittest.makeSuite() by unittest.TestLoader().loadTestsFromTestCase()

* Do not use negative values in argument of Tensor.<type>Max()

The unit tests involving `<type>TestCase.testMaxWrongDim` do not work for
`<type>` being one of `uchar`, `ushort`, `uint`, `ulong`, and
`ulongLong` (which translate to `uint8`, `uint16`, `uint32`, `uint64`, and
`uint64`, respectively). Instead of raising the expected `TypeError`, the
unit tests raise `OverflowError`, with the error message “Python integer -1
out of bounds for <type>”. This is fixed by replacing the negative values
in the argument of the `max` function by positive ones.

* Run unit tests for the SWIG binding at the end of the sdist job

The unit tests will be run in the Linux workflow using the Makefile
distributed in `tools/swig/test` directory. They are run after installation
of NumPy in the system, ensuring that the C header files are correctly
included (see GitHub issue [numpy#30131](numpy#30131)).
IndifferentArea pushed a commit to IndifferentArea/numpy that referenced this pull request Dec 7, 2025
* Replace deprecated unittest.makeSuite() by unittest.TestLoader().loadTestsFromTestCase()

* Do not use negative values in argument of Tensor.<type>Max()

The unit tests involving `<type>TestCase.testMaxWrongDim` do not work for
`<type>` being one of `uchar`, `ushort`, `uint`, `ulong`, and
`ulongLong` (which translate to `uint8`, `uint16`, `uint32`, `uint64`, and
`uint64`, respectively). Instead of raising the expected `TypeError`, the
unit tests raise `OverflowError`, with the error message “Python integer -1
out of bounds for <type>”. This is fixed by replacing the negative values
in the argument of the `max` function by positive ones.

* Run unit tests for the SWIG binding at the end of the sdist job

The unit tests will be run in the Linux workflow using the Makefile
distributed in `tools/swig/test` directory. They are run after installation
of NumPy in the system, ensuring that the C header files are correctly
included (see GitHub issue [numpy#30131](numpy#30131)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Add test for the SWIG interface

2 participants