File tree 1 file changed +43
-0
lines changed
simulation-system/libs/csle-common/tests
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ from unittest .mock import patch
2
+ from csle_common .util .multiprocessing_util import NoDaemonProcess
3
+ from csle_common .util .multiprocessing_util import NoDaemonContext
4
+ from csle_common .util .multiprocessing_util import NestablePool
5
+
6
+
7
+ class TestMultiprocessingUtilSuite :
8
+ """
9
+ Test suite for multiprocessing util
10
+ """
11
+
12
+ def test_daemon (self ) -> None :
13
+ """
14
+ Test the process with daemon property set to false
15
+
16
+ :return: None
17
+ """
18
+ result = NoDaemonProcess (target = lambda : None ).daemon
19
+ assert not result
20
+
21
+ def test_no_daemon_context (self ) -> None :
22
+ """
23
+ Test the NoDaemonContext method
24
+
25
+ :return: None
26
+ """
27
+ context = NoDaemonContext ()
28
+ process = context .Process (target = lambda : None )
29
+ assert isinstance (process , NoDaemonProcess )
30
+ assert not process .daemon
31
+
32
+ @patch ("multiprocessing.get_context" )
33
+ def test_nestable_pool_initialization (self , mock_get_context ) -> None :
34
+ """
35
+ Test the method that initializes the pool
36
+
37
+ :param mock_get_context: mock_get_context
38
+
39
+ :return: None
40
+ """
41
+ mock_get_context .return_value = NoDaemonContext ()
42
+ pool = NestablePool ()
43
+ assert pool
You can’t perform that action at this time.
0 commit comments