Author: Santiago Vila <sanvila@debian.org>
Last-Update: 2024-07-05
Bug-Debian: https://bugs.debian.org/1030885
Description: Skip parallel tests on single-cpu systems

--- a/tests/test_app/test_evo.py
+++ b/tests/test_app/test_evo.py
@@ -2,10 +2,11 @@
 
 from os.path import dirname, join
 from tempfile import TemporaryDirectory
-from unittest import TestCase
+from unittest import TestCase, skipIf
 from unittest.mock import MagicMock
 
 import pytest
+import multiprocessing
 
 from numpy.testing import assert_allclose, assert_raises
 
@@ -846,6 +847,7 @@
             _ = io.load_db() + evo_app.bootstrap(hyp, num_reps=2) + writer
 
 
+@skipIf(multiprocessing.cpu_count() == 1, "Does not work on single-cpu systems")
 def test_bstrap_parallel():
     """exercising bootstrap with parallel"""
     aln = load_aligned_seqs(join(data_dir, "brca1.fasta"), moltype="dna")
--- a/tests/test_app/test_io.py
+++ b/tests/test_app/test_io.py
@@ -9,8 +9,10 @@
 
 import numpy
 import pytest
+import multiprocessing
 
 from numpy.testing import assert_allclose
+from unittest import skipIf
 
 from cogent3 import DNA, get_app, open_data_store
 from cogent3.app import io as io_app
@@ -481,6 +483,7 @@
     assert isinstance(writer.data_store.summary_not_completed, Table)
 
 
+@skipIf(multiprocessing.cpu_count() == 1, "Does not work on single-cpu systems")
 def test_write_db_parallel(tmp_dir, fasta_dir):
     """writing with overwrite in parallel should reset db"""
     dstore = open_data_store(fasta_dir, suffix="fasta")
--- a/tests/test_util/test_parallel.py
+++ b/tests/test_util/test_parallel.py
@@ -25,6 +25,7 @@
 
 
 class ParallelTests(TestCase):
+    @skipIf(multiprocessing.cpu_count() == 1, "Does not work on single-cpu systems")
     def test_create_processes(self):
         """Procressor pool should create multiple distingue processes"""
         max_worker_count = multiprocessing.cpu_count() - 1
@@ -35,6 +36,7 @@
         self.assertEqual(sorted(list(result_values)), index)
         self.assertEqual(len(set(result_processes)), max_worker_count)
 
+    @skipIf(multiprocessing.cpu_count() == 1, "Does not work on single-cpu systems")
     def test_random_seeding(self):
         """Random seed should be set every function call"""
         # On Windows process ids are not guaranteed to be sequential(1,2,3,4...)
@@ -46,6 +48,7 @@
         self.assertEqual(result1[0], result2[0])
         self.assertNotEqual(result1, result2)
 
+    @skipIf(multiprocessing.cpu_count() == 1, "Does not work on single-cpu systems")
     @skipIf(sys.version_info[1] < 7, "method exclusive to Python 3.7 and above")
     def test_is_master_process(self):
         """
