Skip to content

Commit

Permalink
gh-106458: Mark testthreadingmock.py with `@requires_working_thread…
Browse files Browse the repository at this point in the history
…ing` (GH-106366)

Mark `testthreadingmock.py` with `threading_helper.requires_working_threading`.

Also add longer delays to reduce the change of a race conditions on the tests that validate short timeouts.

Backports: 56353b10023ff12c7c8d6288ae4bf7bdcd5d4b6c
Signed-off-by: Chris Withers <chris@simplistix.co.uk>
  • Loading branch information
mariocj89 authored and cjw296 committed Jul 11, 2023
1 parent 0dc15d4 commit 9cbc589
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lastsync.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3f7c0810f6158a7ff37be432f8d7f9511427489f
2dfc7fae787e65726f24bfe9efe05418b05ee8e2
16 changes: 7 additions & 9 deletions mock/tests/testthreadingmock.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,9 @@ def test_wait_failed_with_timeout_override(self):

with patch(f"{__name__}.Something", waitable_mock):
something = Something()
self.run_async(something.method_1, delay=0.1)
self.run_async(something.method_1, delay=0.5)
with self.assertRaises(AssertionError):
something.method_1.wait_until_called(timeout=0.05)
with self.assertRaises(AssertionError):
something.method_1.wait_until_any_call_with(timeout=0.05)

def test_wait_success_called_before(self):
waitable_mock = self._make_mock()
Expand All @@ -163,10 +161,10 @@ def test_wait_until_any_call_with_positional(self):

with patch(f"{__name__}.Something", waitable_mock):
something = Something()
self.run_async(something.method_1, 1, delay=0.1)
self.run_async(something.method_1, 2, delay=0.2)
self.run_async(something.method_1, 3, delay=0.3)
self.run_async(something.method_1, 1, delay=0.2)
self.assertNotIn(call(1), something.method_1.mock_calls)
self.run_async(something.method_1, 2, delay=0.5)
self.run_async(something.method_1, 3, delay=0.6)

something.method_1.wait_until_any_call_with(1)
something.method_1.assert_called_with(1)
Expand All @@ -182,10 +180,10 @@ def test_wait_until_any_call_with_keywords(self):

with patch(f"{__name__}.Something", waitable_mock):
something = Something()
self.run_async(something.method_1, a=1, delay=0.1)
self.run_async(something.method_1, b=2, delay=0.2)
self.run_async(something.method_1, c=3, delay=0.3)
self.run_async(something.method_1, a=1, delay=0.2)
self.assertNotIn(call(a=1), something.method_1.mock_calls)
self.run_async(something.method_1, b=2, delay=0.5)
self.run_async(something.method_1, c=3, delay=0.6)

something.method_1.wait_until_any_call_with(a=1)
something.method_1.assert_called_with(a=1)
Expand Down

0 comments on commit 9cbc589

Please sign in to comment.