Lines Matching refs:mock

10 import mock
37 instance = mock.Mock()
39 testsuite = mock.Mock()
40 type(testsuite).source_dir = mock.PropertyMock(return_value='')
45 type(instance).build_dir = mock.PropertyMock(return_value=str(build_dir))
47 platform = mock.Mock()
48 type(platform).binaries = mock.PropertyMock(return_value=[])
51 type(instance.testsuite).timeout = mock.PropertyMock(return_value=60)
52 type(instance.platform).timeout_multiplier = mock.PropertyMock(
110 with mock.patch('os.name', os_name), \
111 mock.patch.dict('sys.modules', modules_mock, clear=True), \
112 mock.patch('sys.meta_path', meta_path_mock), \
122 instance.testcases = [mock.Mock()]
128 harness.state = mock.Mock()
129 harness.detected_suite_names = mock.Mock()
133 handler_time = mock.Mock()
170 handler_time = mock.Mock()
172 with mock.patch.object(Handler, '_missing_suite_name') as _missing_mocked:
188 instance.testcases = [mock.Mock()]
195 handler_time = mock.Mock()
209 instance.testcases = [mock.Mock()]
218 with mock.patch(
220 mock.mock_open(read_data='')
222 mock.patch(
224 mock.Mock()
226 mock.patch(
228 mock.Mock()
239 mock_writeheader.assert_has_calls([mock.call({ k:k for k in harness.recording[0].keys()})])
240 mock_writerows.assert_has_calls([mock.call(harness.recording)])
252 mock_process = mock.Mock()
253 mock_child1 = mock.Mock(pid=1)
254 mock_child2 = mock.Mock(pid=2)
255 mock_process.children = mock.Mock(return_value=[mock_child1, mock_child2])
257 mock_proc = mock.Mock(pid=0)
258 mock_proc.terminate = mock.Mock(return_value=None)
259 mock_proc.kill = mock.Mock(return_value=None)
261 with mock.patch('psutil.Process', return_value=mock_process), \
262 mock.patch(
264 mock.Mock(side_effect=mock_kill_function)
272 [mock.call(1, signal.SIGTERM), mock.call(2, signal.SIGTERM)]
275 mock_child_neg1 = mock.Mock(pid=-1)
276 mock_process.children = mock.Mock(
285 [mock.call(-1, signal.SIGTERM), mock.call(2, signal.SIGTERM)]
299 with mock.patch(
301 mock.Mock(side_effect=mock_kill_function)
303 mock.patch('os.unlink', mock.Mock()) as mock_unlink:
304 with mock.patch('builtins.open', mock.mock_open(read_data='1')):
316 with mock.patch('builtins.open', mock.mock_open(read_data='-1')):
328 mock.Mock(state=False, capture_coverage=False),
330 mock.call('This\\r\\n'),
331 mock.call('is\r'),
332 mock.call('a short'),
333 mock.call('file.')
336 mock.call('This'),
337 mock.call('is'),
338 mock.call('a short'),
339 mock.call('file.')
346 mock.Mock(state=False, capture_coverage=False),
354 mock.Mock(state=True, capture_coverage=False),
362 mock.Mock(state=True, capture_coverage=True),
391 class MockStdout(mock.Mock):
406 class MockProc(mock.Mock):
409 self.pid = mock.PropertyMock(return_value=pid)
417 handler.terminate = mock.Mock()
418 handler.options = mock.Mock(timeout_multiplier=1)
422 with mock.patch(
424 mock.mock_open(read_data='')
426 mock.patch('time.time', side_effect=faux_timer.time):
477 handler.options = mock.Mock(enable_valgrind=enable_valgrind)
506 handler.options = mock.Mock(
518 with mock.patch('os.environ', env):
564 handler.options = mock.Mock(enable_valgrind=enable_valgrind)
565 missing_mock = mock.Mock()
597 thread_mock_obj = mock.Mock()
600 return mock.Mock(
601 __enter__=mock.Mock(return_value=mock.Mock(pid=0, returncode=0)),
602 __exit__=mock.Mock(return_value=None)
612 handler._create_command = mock.Mock(return_value=['dummy' , 'command'])
613 handler._create_env = mock.Mock(return_value=[])
614 handler._update_instance_info = mock.Mock()
615 handler._final_handle_actions = mock.Mock()
616 handler.terminate = mock.Mock()
617 handler.try_kill_process_by_pid = mock.Mock()
618 handler.options = mock.Mock(coverage=coverage)
620 robot_mock = mock.Mock()
621 harness = mock.Mock(is_robot_test=is_robot_test, run_robot_test=robot_mock)
623 popen_mock = mock.Mock(side_effect=mock_popen)
624 thread_mock = mock.Mock(side_effect=mock_thread)
625 call_mock = mock.Mock()
627 with mock.patch('subprocess.call', call_mock), \
628 mock.patch('subprocess.Popen', popen_mock), \
629 mock.patch('threading.Thread', thread_mock), \
630 mock.patch('sys.stdout.isatty', return_value=isatty):
634 robot_mock.assert_called_once_with(['dummy', 'command'], mock.ANY)
644 call_mock.assert_any_call(['stty', 'sane'], stdin=mock.ANY)
730 halt_event = mock.Mock(is_set=mock.Mock(side_effect=is_set_iter))
731 ser = mock.Mock(
732 isOpen=mock.Mock(side_effect=is_open_iter),
733 readline=mock.Mock(side_effect=line_iter)
735 type(ser).in_waiting = mock.PropertyMock(
739 harness = mock.Mock(capture_coverage=False)
740 type(harness).state=mock.PropertyMock(side_effect=state_iter)
743 handler.options = mock.Mock(enable_coverage=not end_by_state)
745 with mock.patch('builtins.open', mock.mock_open(read_data='')):
752 [mock.call(f'line no {idx}') for idx in range(expected_line_count)]
761 mock.Mock(
767 mock.Mock(
773 mock.Mock(
781 mock.Mock(
784 serial_pty=mock.Mock(),
801 mock.Mock(
804 serial_pty=mock.Mock(),
807 mock.Mock(
810 serial_pty=mock.Mock(),
813 mock.Mock(
816 serial=mock.Mock(),
819 mock.Mock(
822 serial=mock.Mock(),
866 serial = mock.Mock(name='dummy_serial')
868 mock.Mock(available=0, serial=serial, serial_pty=None),
869 mock.Mock(available=0, serial=None, serial_pty=serial),
870 mock.Mock(
872 serial=mock.Mock('another_serial'),
887 (mock.Mock(pid=0, returncode=0), False),
888 (mock.Mock(pid=0, returncode=1), False),
889 (mock.Mock(pid=0, returncode=1), True)
902 return mock.Mock(), mock.Mock()
905 return mock.Mock(
906 __enter__=mock.Mock(return_value=mock_process),
907 __exit__=mock.Mock(return_value=None)
910 mock_process.communicate = mock.Mock(side_effect=raise_timeout_fn)
915 with mock.patch('subprocess.Popen', side_effect=assert_popen):
924 mock.call.communicate(timeout=timeout),
925 mock.call.kill(),
926 mock.call.communicate()
953 expected_hardware = mock.Mock()
966 with mock.patch.object(
1095 handler.options = mock.Mock(west_flash=self_west_flash)
1101 hardware = mock.Mock(
1137 missing_mock = mock.Mock()
1156 mock.Mock(communicate=mock.Mock(return_value=('', ''))),
1195 handler.make_device_available = mock.Mock()
1196 missing_mock = mock.Mock()
1198 available_mock = mock.Mock()
1200 handler.options = mock.Mock(timeout_multiplier=1)
1204 serial_mock = mock.Mock(side_effect=mock_serial)
1206 with mock.patch('serial.Serial', serial_mock), \
1251 return mock.Mock()
1256 popen_mock = mock.Mock(side_effect=mock_popen)
1257 openpty_mock = mock.Mock(return_value=('master', 'slave'))
1258 ttyname_mock = mock.Mock(side_effect=lambda x: x + ' name')
1260 with mock.patch('subprocess.Popen', popen_mock), \
1261 mock.patch('pty.openpty', openpty_mock), \
1262 mock.patch('os.ttyname', ttyname_mock):
1311 serial_pty_process = mock.Mock(
1313 communicate=mock.Mock(
1323 return mock.Mock(name='dummy serial')
1326 is_alive_mock = mock.Mock(return_value=bool(do_timeout_thread))
1328 return mock.Mock(is_alive=is_alive_mock)
1331 proc.communicate = mock.Mock(return_value=(mock.Mock(), mock.Mock()))
1336 return mock.Mock(), mock.Mock()
1342 mock_process = mock.Mock(
1345 communicate=mock.Mock(side_effect=mock_communicate)
1348 return mock.Mock(
1349 __enter__=mock.Mock(return_value=mock_process),
1350 __exit__=mock.Mock(return_value=None)
1353 hardware = None if not has_hardware else mock.Mock(
1366 handler.get_hardware = mock.Mock(return_value=hardware)
1367 handler.options = mock.Mock(
1372 handler._get_serial_device = mock.Mock(side_effect=mock_get_serial)
1373 handler._create_command = mock.Mock(return_value=['dummy', 'command'])
1374 handler.run_custom_script = mock.Mock()
1375 handler._create_serial_connection = mock.Mock(
1378 handler.monitor_serial = mock.Mock()
1379 handler.terminate = mock.Mock(side_effect=mock_terminate)
1380 handler._update_instance_info = mock.Mock()
1381 handler._final_handle_actions = mock.Mock()
1382 handler.make_device_available = mock.Mock()
1385 harness = mock.Mock()
1387 with mock.patch('builtins.open', mock.mock_open(read_data='')), \
1388 mock.patch('subprocess.Popen', side_effect=mock_popen), \
1389 mock.patch('threading.Event', mock.Mock()), \
1390 mock.patch('threading.Thread', side_effect=mock_thread):
1402 mock.call('dummy pre script', mock.ANY)
1409 mock.call('dummy pre script', mock.ANY),
1410 mock.call('dummy post flash script', mock.ANY),
1411 mock.call('dummy post script', mock.ANY)
1450 return mock.Mock(
1451 cpu_times=mock.Mock(
1452 return_value=mock.Mock(
1459 with mock.patch('psutil.Process', mock_process):
1469 mock.PropertyMock(return_value=os.path.join('dummy_dir', '1')),
1475 mock.PropertyMock(return_value=os.path.join('dummy_dir', '2')),
1492 get_default_domain_mock = mock.Mock()
1494 domains_mock = mock.Mock(get_default_domain=get_default_domain_mock)
1495 from_file_mock = mock.Mock(return_value=domains_mock)
1501 with mock.patch('domains.Domains.from_file', from_file_mock):
1534 unlink_mock = mock.Mock()
1535 exists_mock = mock.Mock(return_value=exists_pid_fn)
1541 with mock.patch('os.unlink', unlink_mock), \
1542 mock.patch('os.path.exists', exists_mock):
1640 mocked_instance.add_missing_case_status = mock.Mock()
1687 unlink_mock = mock.Mock()
1688 exists_mock = mock.Mock(side_effect=mock_exists)
1689 mkfifo_mock = mock.Mock()
1695 with mock.patch('os.unlink', unlink_mock), \
1696 mock.patch('os.mkfifo', mkfifo_mock), \
1697 mock.patch('os.path.exists', exists_mock), \
1698 mock.patch('builtins.open', mock.mock_open()) as open_mock:
1702 mock.call('fifo.in', 'wb'),
1703 mock.call('fifo.out', 'rb', buffering=0),
1704 mock.call('log.file', 'wt'),
1734 unlink_mock = mock.Mock()
1735 kill_mock = mock.Mock(side_effect=mock_kill)
1740 out_fp = mock.Mock()
1741 in_fp = mock.Mock()
1742 log_out_fp = mock.Mock()
1744 with mock.patch('os.unlink', unlink_mock), \
1745 mock.patch('os.kill', kill_mock):
1753 unlink_mock.assert_has_calls([mock.call('fifo.in'), mock.call('fifo.out')])
1798 [mock.call('1\n'), mock.call('1\n')]
1808 [mock.call('1\n'), mock.call('1\n')]
1838 [mock.call('1\n'), mock.call('2\n'), mock.call('3\n'), mock.call('4\n')]
1848 [mock.call('1\n'), mock.call('2\n')]
1858 [mock.call('1\n'), mock.call('2\n'), mock.call('3\n'), mock.call('4\n')]
1894 type(mocked_instance.testsuite).timeout = mock.PropertyMock(return_value=timeout)
1900 handler.options = mock.Mock(timeout_multiplier=1)
1910 file_object = mock.mock_open(read_data=contents).return_value
1914 harness = mock.Mock(capture_coverage=capture_coverage, handle=print)
1915 type(harness).state = mock.PropertyMock(side_effect=harness_states)
1917 p = mock.Mock()
1918 p.poll = mock.Mock(
1922 mock_thread_get_fifo_names = mock.Mock(
1925 log_fp_mock = mock.Mock()
1927 out_fp_mock = mock.Mock()
1928 mock_thread_open_files = mock.Mock(
1931 mock_thread_close_files = mock.Mock()
1932 mock_thread_update_instance_info = mock.Mock()
1934 with mock.patch('time.time', side_effect=faux_timer.time), \
1935 mock.patch('builtins.open', new=mocked_open), \
1936 mock.patch('select.poll', return_value=p), \
1937 mock.patch('os.path.exists', return_value=True), \
1938 mock.patch('twisterlib.handlers.QEMUHandler._get_cpu_time',
1940 mock.patch('twisterlib.handlers.QEMUHandler._thread_get_fifo_names',
1942 mock.patch('twisterlib.handlers.QEMUHandler._thread_open_files',
1944 mock.patch('twisterlib.handlers.QEMUHandler._thread_close_files',
1946 mock.patch('twisterlib.handlers.QEMUHandler.' \
1963 mock.ANY,
1997 mock_process = mock.Mock(pid=0, returncode=1)
1998 mock_process.communicate = mock.Mock(
1999 return_value=(mock.Mock(), mock.Mock())
2001 mock_process.wait = mock.Mock(side_effect=mock_wait)
2009 return mock.Mock(
2010 __enter__=mock.Mock(return_value=mock_process),
2011 __exit__=mock.Mock(return_value=None),
2012 communicate=mock.Mock(return_value=(mock.Mock(), mock.Mock()))
2016 return mock.Mock()
2023 harness = mock.Mock(state=harness_state)
2029 handler.options = mock.Mock(
2034 handler.run_custom_script = mock.Mock(return_value=None)
2035 handler.make_device_available = mock.Mock(return_value=None)
2036 handler._final_handle_actions = mock.Mock(return_value=None)
2037 handler._create_command = mock.Mock(return_value=command)
2038 handler._set_qemu_filenames = mock.Mock(side_effect=mock_filenames)
2039 handler._get_sysbuild_build_dir = mock.Mock(return_value=sysbuild_build_dir)
2040 handler.terminate = mock.Mock()
2042 unlink_mock = mock.Mock()
2044 with mock.patch('subprocess.Popen', side_effect=mock_popen), \
2045 mock.patch('builtins.open', mock.mock_open(read_data='1')), \
2046 mock.patch('threading.Thread', side_effect=mock_thread), \
2047 mock.patch('os.path.exists', side_effect=mock_path_exists), \
2048 mock.patch('os.unlink', unlink_mock), \
2049 mock.patch('sys.stdout.isatty', return_value=isatty):