2
2
import unittest
3
3
import concurrent .futures
4
4
5
+ from test .support import threading_helper
5
6
from unittest .mock import patch , ThreadingMock , call
6
7
7
8
9
+ threading_helper .requires_working_threading (module = True )
10
+
11
+
8
12
class Something :
9
13
def method_1 (self ):
10
14
pass
@@ -133,11 +137,9 @@ def test_wait_failed_with_timeout_override(self):
133
137
134
138
with patch (f"{ __name__ } .Something" , waitable_mock ):
135
139
something = Something ()
136
- self .run_async (something .method_1 , delay = 0.1 )
140
+ self .run_async (something .method_1 , delay = 0.5 )
137
141
with self .assertRaises (AssertionError ):
138
142
something .method_1 .wait_until_called (timeout = 0.05 )
139
- with self .assertRaises (AssertionError ):
140
- something .method_1 .wait_until_any_call_with (timeout = 0.05 )
141
143
142
144
def test_wait_success_called_before (self ):
143
145
waitable_mock = self ._make_mock ()
@@ -163,10 +165,10 @@ def test_wait_until_any_call_with_positional(self):
163
165
164
166
with patch (f"{ __name__ } .Something" , waitable_mock ):
165
167
something = Something ()
166
- self .run_async (something .method_1 , 1 , delay = 0.1 )
167
- self .run_async (something .method_1 , 2 , delay = 0.2 )
168
- self .run_async (something .method_1 , 3 , delay = 0.3 )
168
+ self .run_async (something .method_1 , 1 , delay = 0.2 )
169
169
self .assertNotIn (call (1 ), something .method_1 .mock_calls )
170
+ self .run_async (something .method_1 , 2 , delay = 0.5 )
171
+ self .run_async (something .method_1 , 3 , delay = 0.6 )
170
172
171
173
something .method_1 .wait_until_any_call_with (1 )
172
174
something .method_1 .assert_called_with (1 )
@@ -182,10 +184,10 @@ def test_wait_until_any_call_with_keywords(self):
182
184
183
185
with patch (f"{ __name__ } .Something" , waitable_mock ):
184
186
something = Something ()
185
- self .run_async (something .method_1 , a = 1 , delay = 0.1 )
186
- self .run_async (something .method_1 , b = 2 , delay = 0.2 )
187
- self .run_async (something .method_1 , c = 3 , delay = 0.3 )
187
+ self .run_async (something .method_1 , a = 1 , delay = 0.2 )
188
188
self .assertNotIn (call (a = 1 ), something .method_1 .mock_calls )
189
+ self .run_async (something .method_1 , b = 2 , delay = 0.5 )
190
+ self .run_async (something .method_1 , c = 3 , delay = 0.6 )
189
191
190
192
something .method_1 .wait_until_any_call_with (a = 1 )
191
193
something .method_1 .assert_called_with (a = 1 )
0 commit comments