Author: Santiago Vila <sanvila@debian.org>
Last-Update: 2023-12-13
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
@@ -1,5 +1,7 @@
+import multiprocessing
+
 from os.path import dirname, join
-from unittest import TestCase, main
+from unittest import TestCase, main, skipIf
 from unittest.mock import MagicMock
 
 from numpy.testing import assert_allclose, assert_raises
@@ -670,6 +672,7 @@
         got = deserialise_object(json)
         self.assertIsInstance(got, evo_app.bootstrap_result)
 
+    @skipIf(multiprocessing.cpu_count() == 1, "Does not work on single-cpu systems")
     def test_bstrap_parallel(self):
         """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
@@ -3,10 +3,11 @@
 import pathlib
 import shutil
 import zipfile
+import multiprocessing
 
 from os.path import basename, join
 from tempfile import TemporaryDirectory
-from unittest import TestCase, main
+from unittest import TestCase, main, skipIf
 from unittest.mock import Mock, patch
 
 import numpy
@@ -532,6 +533,7 @@
             w = io_app.write_db(outdir, create=True, if_exists="skip")
             w.data_store.close()
 
+    @skipIf(multiprocessing.cpu_count() == 1, "Does not work on single-cpu systems")
     def test_write_db_parallel(self):
         """writing with overwrite in parallel should reset db"""
         dstore = io_app.get_data_store(self.basedir, suffix="fasta")
--- a/tests/test_util/test_parallel.py
+++ b/tests/test_util/test_parallel.py
@@ -35,6 +35,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
@@ -45,6 +46,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...)
@@ -56,6 +58,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):
         """
