From: Santiago Vila Date: Mon, 11 May 2026 14:00:25 +1000 Subject: Conditionally skip tests requiring more CPUs than available --- numba/tests/test_parallel_backend.py | 7 +++++++ numba/tests/test_parfors.py | 1 + 2 files changed, 8 insertions(+) --- a/numba/tests/test_parallel_backend.py +++ b/numba/tests/test_parallel_backend.py @@ -433,6 +433,13 @@ TestSpecificBackend.generate() +_skip = unittest.skipIf(config.NUMBA_NUM_THREADS < 2, "Not enough CPU cores") +for _name in ( + 'test_random_concurrent_mix_use_tbb', + 'test_random_concurrent_vectorize_tbb', + 'test_threading_concurrent_mix_use_tbb', +): + setattr(TestSpecificBackend, _name, _skip(getattr(TestSpecificBackend, _name))) class ThreadLayerTestHelper(TestCase): """ --- a/numba/tests/test_parfors.py +++ b/numba/tests/test_parfors.py @@ -4881,6 +4881,7 @@ @skip_parfors_unsupported +@unittest.skipIf(config.NUMBA_NUM_THREADS < 2, "Not enough CPU cores") class TestParforReductionSetNumThreads(TestCase): """Test execution correctness on reductions with set_num_threads. """ --- a/numba/tests/test_array_analysis.py +++ b/numba/tests/test_array_analysis.py @@ -6,6 +6,7 @@ from io import StringIO from numba import njit, typeof, prange +from numba.core import config from numba.core import ( types, typing, @@ -1051,6 +1052,7 @@ np.testing.assert_array_equal(test_impl(data), test_impl.py_func(data)) @skip_unsupported + @unittest.skipIf(config.NUMBA_NUM_THREADS < 2, "Not enough CPU cores") def test_global_tuple(self): """make sure a global tuple with non-integer values does not cause errors (test for #6726). --- a/numba/tests/test_remove_dead.py +++ b/numba/tests/test_remove_dead.py @@ -25,6 +25,7 @@ IRLegalization, NoPythonBackend, NativeLowering) import numpy as np from numba.tests.support import skip_parfors_unsupported, needs_blas, TestCase +from numba.core import config import unittest @@ -295,6 +296,15 @@ np.testing.assert_array_equal(test_res, py_res) +_skip = unittest.skipIf(config.NUMBA_NUM_THREADS < 2, "Not enough CPU cores") +for _name in ( + 'test_alias_flat', + 'test_alias_transpose2', + 'test_alias_func_ext', +): + setattr(TestRemoveDead, _name, _skip(getattr(TestRemoveDead, _name))) + + class TestSSADeadBranchPrune(TestCase): """ Test issues that required dead-branch-prune on SSA IR --- a/numba/tests/test_try_except.py +++ b/numba/tests/test_try_except.py @@ -5,6 +5,7 @@ import numpy as np from numba import njit, typed, objmode, prange +from numba.core import config from numba.core import ir_utils, ir from numba.core.errors import ( CompilerError, NumbaPerformanceWarning, TypingError, @@ -847,5 +848,12 @@ self.assertPreciseEqual(njit(parallel=True)(udt)(*args), expect) +_skip = unittest.skipIf(config.NUMBA_NUM_THREADS < 2, "Not enough CPU cores") +for _name in ( + 'test_try_in_prange_reduction', + 'test_try_in_prange_map', +): + setattr(TestTryExceptParfors, _name, _skip(getattr(TestTryExceptParfors, _name))) + if __name__ == '__main__': unittest.main()