Skip to content

Commit 5be9eff

Browse files
author
ShresthSamyak
committed
test(macos): fix mock types and sentinels for CFRunLoop review
1 parent a7f7278 commit 5be9eff

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

tests/test_mpv.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -999,15 +999,18 @@ def test_macos_wait_for_future(self):
999999
with mock.patch('threading.current_thread') as mock_current_thread, \
10001000
mock.patch('threading.main_thread') as mock_main_thread, \
10011001
mock.patch('ctypes.cdll.LoadLibrary') as mock_load_library, \
1002-
mock.patch('ctypes.util.find_library') as mock_find_library:
1002+
mock.patch('ctypes.util.find_library') as mock_find_library, \
1003+
mock.patch('ctypes.c_void_p.in_dll') as mock_in_dll:
10031004

1004-
# Make sure threading check passes
1005-
mock_current_thread.return_value = 'main'
1006-
mock_main_thread.return_value = 'main'
1005+
sentinel = object()
1006+
# Make sure threading check passes WITHOUT string interning
1007+
mock_current_thread.return_value = sentinel
1008+
mock_main_thread.return_value = sentinel
10071009

10081010
# Setup CFRunLoopRunInMode mock
10091011
mock_cf = mock.Mock()
10101012
mock_load_library.return_value = mock_cf
1013+
mock_in_dll.return_value = mock.Mock()
10111014

10121015
# Reset globals from mpv module to force re-initialization
10131016
mpv._core_foundation = None
@@ -1034,13 +1037,16 @@ def test_macos_wait_for_future_timeout(self):
10341037
with mock.patch('threading.current_thread') as mock_current_thread, \
10351038
mock.patch('threading.main_thread') as mock_main_thread, \
10361039
mock.patch('ctypes.cdll.LoadLibrary') as mock_load_library, \
1037-
mock.patch('ctypes.util.find_library') as mock_find_library:
1040+
mock.patch('ctypes.util.find_library') as mock_find_library, \
1041+
mock.patch('ctypes.c_void_p.in_dll') as mock_in_dll:
10381042

1039-
mock_current_thread.return_value = 'main'
1040-
mock_main_thread.return_value = 'main'
1043+
sentinel = object()
1044+
mock_current_thread.return_value = sentinel
1045+
mock_main_thread.return_value = sentinel
10411046

10421047
mock_cf = mock.Mock()
10431048
mock_load_library.return_value = mock_cf
1049+
mock_in_dll.return_value = mock.Mock()
10441050

10451051
mpv._core_foundation = None
10461052
mpv._cf_runloop_default_mode = None

0 commit comments

Comments
 (0)