Browse Source

travis friendly

Bastien Sevajol 7 years ago
parent
commit
875080b2f5
1 changed files with 8 additions and 9 deletions
  1. 8 9
      tests/test_processing.py

+ 8 - 9
tests/test_processing.py View File

1
 # coding: utf-8
1
 # coding: utf-8
2
 import os
2
 import os
3
-
4
-import multiprocessing
5
-
6
 import psutil
3
 import psutil
7
 import pytest
4
 import pytest
8
 
5
 
10
 from synergine2.utils import ChunkManager
7
 from synergine2.utils import ChunkManager
11
 from tests import BaseTest
8
 from tests import BaseTest
12
 
9
 
10
+available_cores = len(psutil.Process().cpu_affinity())
11
+
13
 
12
 
14
 class MyFakeClass(object):
13
 class MyFakeClass(object):
15
     def __init__(self, value):
14
     def __init__(self, value):
38
         result = sum(data)
37
         result = sum(data)
39
         return current_pid, MyFakeClass(result)
38
         return current_pid, MyFakeClass(result)
40
 
39
 
41
-    @pytest.mark.skipif(len(psutil.Process().cpu_affinity()) < 2, reason="requires 2 or more cpus")
40
+    @pytest.mark.skipif(available_cores < 2, reason="requires 2 or more cpus")
42
     def test_parallel_jobs_with_scalar(self):
41
     def test_parallel_jobs_with_scalar(self):
43
-        chunk_manager = ChunkManager(2)
42
+        chunk_manager = ChunkManager(available_cores)
44
         process_manager = ProcessManager(
43
         process_manager = ProcessManager(
45
-            process_count=2,
44
+            process_count=available_cores,
46
             chunk_manager=chunk_manager,
45
             chunk_manager=chunk_manager,
47
         )
46
         )
48
 
47
 
84
         assert process_id == os.getpid()
83
         assert process_id == os.getpid()
85
         assert final_result == 4950
84
         assert final_result == 4950
86
 
85
 
87
-    @pytest.mark.skipif(len(psutil.Process().cpu_affinity()) < 2, reason="requires 2 or more cpus")
86
+    @pytest.mark.skipif(available_cores < 2, reason="requires 2 or more cpus")
88
     def test_parallel_jobs_with_objects(self):
87
     def test_parallel_jobs_with_objects(self):
89
-        chunk_manager = ChunkManager(4)
88
+        chunk_manager = ChunkManager(available_cores)
90
         process_manager = ProcessManager(
89
         process_manager = ProcessManager(
91
-            process_count=4,
90
+            process_count=available_cores,
92
             chunk_manager=chunk_manager,
91
             chunk_manager=chunk_manager,
93
         )
92
         )
94
 
93