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()]
216 type(harness).fieldnames = mock.PropertyMock(return_value=[])
218 mock_writerow = mock.Mock()
219 mock_writer = mock.Mock(writerow=mock_writerow)
221 with mock.patch(
223 mock.mock_open(read_data='')
225 mock.patch(
227 mock.Mock(return_value=mock_writer)
243 [mock.call(harness.fieldnames)] + \
244 [mock.call(recording) for recording in harness.recording]
257 mock_process = mock.Mock()
258 mock_child1 = mock.Mock(pid=1)
259 mock_child2 = mock.Mock(pid=2)
260 mock_process.children = mock.Mock(return_value=[mock_child1, mock_child2])
262 mock_proc = mock.Mock(pid=0)
263 mock_proc.terminate = mock.Mock(return_value=None)
264 mock_proc.kill = mock.Mock(return_value=None)
266 with mock.patch('psutil.Process', return_value=mock_process), \
267 mock.patch(
269 mock.Mock(side_effect=mock_kill_function)
277 [mock.call(1, signal.SIGTERM), mock.call(2, signal.SIGTERM)]
280 mock_child_neg1 = mock.Mock(pid=-1)
281 mock_process.children = mock.Mock(
290 [mock.call(-1, signal.SIGTERM), mock.call(2, signal.SIGTERM)]
304 with mock.patch(
306 mock.Mock(side_effect=mock_kill_function)
308 mock.patch('os.unlink', mock.Mock()) as mock_unlink:
309 with mock.patch('builtins.open', mock.mock_open(read_data='1')):
321 with mock.patch('builtins.open', mock.mock_open(read_data='-1')):
333 mock.Mock(state=False, capture_coverage=False),
335 mock.call('This\\r\\n'),
336 mock.call('is\r'),
337 mock.call('a short'),
338 mock.call('file.')
341 mock.call('This'),
342 mock.call('is'),
343 mock.call('a short'),
344 mock.call('file.')
351 mock.Mock(state=False, capture_coverage=False),
359 mock.Mock(state=True, capture_coverage=False),
367 mock.Mock(state=True, capture_coverage=True),
396 class MockStdout(mock.Mock):
411 class MockProc(mock.Mock):
414 self.pid = mock.PropertyMock(return_value=pid)
422 handler.terminate = mock.Mock()
423 handler.options = mock.Mock(timeout_multiplier=1)
427 with mock.patch(
429 mock.mock_open(read_data='')
431 mock.patch('time.time', side_effect=faux_timer.time):
482 handler.options = mock.Mock(enable_valgrind=enable_valgrind)
511 handler.options = mock.Mock(
523 with mock.patch('os.environ', env):
569 handler.options = mock.Mock(enable_valgrind=enable_valgrind)
570 missing_mock = mock.Mock()
602 thread_mock_obj = mock.Mock()
605 return mock.Mock(
606 __enter__=mock.Mock(return_value=mock.Mock(pid=0, returncode=0)),
607 __exit__=mock.Mock(return_value=None)
617 handler._create_command = mock.Mock(return_value=['dummy' , 'command'])
618 handler._create_env = mock.Mock(return_value=[])
619 handler._update_instance_info = mock.Mock()
620 handler._final_handle_actions = mock.Mock()
621 handler.terminate = mock.Mock()
622 handler.try_kill_process_by_pid = mock.Mock()
623 handler.options = mock.Mock(coverage=coverage)
625 robot_mock = mock.Mock()
626 harness = mock.Mock(is_robot_test=is_robot_test, run_robot_test=robot_mock)
628 popen_mock = mock.Mock(side_effect=mock_popen)
629 thread_mock = mock.Mock(side_effect=mock_thread)
630 call_mock = mock.Mock()
632 with mock.patch('subprocess.call', call_mock), \
633 mock.patch('subprocess.Popen', popen_mock), \
634 mock.patch('threading.Thread', thread_mock), \
635 mock.patch('sys.stdout.isatty', return_value=isatty):
639 robot_mock.assert_called_once_with(['dummy', 'command'], mock.ANY)
656 call_mock.assert_any_call(['stty', 'sane'], stdin=mock.ANY)
742 halt_event = mock.Mock(is_set=mock.Mock(side_effect=is_set_iter))
743 ser = mock.Mock(
744 isOpen=mock.Mock(side_effect=is_open_iter),
745 readline=mock.Mock(side_effect=line_iter)
747 type(ser).in_waiting = mock.PropertyMock(
751 harness = mock.Mock(capture_coverage=False)
752 type(harness).state=mock.PropertyMock(side_effect=state_iter)
755 handler.options = mock.Mock(coverage=not end_by_state)
757 with mock.patch('builtins.open', mock.mock_open(read_data='')):
764 [mock.call(f'line no {idx}') for idx in range(expected_line_count)]
773 mock.Mock(
779 mock.Mock(
785 mock.Mock(
793 mock.Mock(
796 serial_pty=mock.Mock(),
813 mock.Mock(
816 serial_pty=mock.Mock(),
819 mock.Mock(
822 serial_pty=mock.Mock(),
825 mock.Mock(
828 serial=mock.Mock(),
831 mock.Mock(
834 serial=mock.Mock(),
878 serial = mock.Mock(name='dummy_serial')
880 mock.Mock(available=0, serial=serial, serial_pty=None),
881 mock.Mock(available=0, serial=None, serial_pty=serial),
882 mock.Mock(
884 serial=mock.Mock('another_serial'),
899 (mock.Mock(pid=0, returncode=0), False),
900 (mock.Mock(pid=0, returncode=1), False),
901 (mock.Mock(pid=0, returncode=1), True)
914 return mock.Mock(), mock.Mock()
917 return mock.Mock(
918 __enter__=mock.Mock(return_value=mock_process),
919 __exit__=mock.Mock(return_value=None)
922 mock_process.communicate = mock.Mock(side_effect=raise_timeout_fn)
927 with mock.patch('subprocess.Popen', side_effect=assert_popen):
936 mock.call.communicate(timeout=timeout),
937 mock.call.kill(),
938 mock.call.communicate()
965 expected_hardware = mock.Mock()
978 with mock.patch.object(
1107 handler.options = mock.Mock(west_flash=self_west_flash)
1113 hardware = mock.Mock(
1149 missing_mock = mock.Mock()
1168 mock.Mock(communicate=mock.Mock(return_value=('', ''))),
1207 handler.make_device_available = mock.Mock()
1208 missing_mock = mock.Mock()
1210 available_mock = mock.Mock()
1212 handler.options = mock.Mock(timeout_multiplier=1)
1216 serial_mock = mock.Mock(side_effect=mock_serial)
1218 with mock.patch('serial.Serial', serial_mock), \
1263 return mock.Mock()
1268 popen_mock = mock.Mock(side_effect=mock_popen)
1269 openpty_mock = mock.Mock(return_value=('master', 'slave'))
1270 ttyname_mock = mock.Mock(side_effect=lambda x: x + ' name')
1272 with mock.patch('subprocess.Popen', popen_mock), \
1273 mock.patch('pty.openpty', openpty_mock), \
1274 mock.patch('os.ttyname', ttyname_mock):
1323 serial_pty_process = mock.Mock(
1325 communicate=mock.Mock(
1335 return mock.Mock(name='dummy serial')
1338 is_alive_mock = mock.Mock(return_value=bool(do_timeout_thread))
1340 return mock.Mock(is_alive=is_alive_mock)
1343 proc.communicate = mock.Mock(return_value=(mock.Mock(), mock.Mock()))
1348 return mock.Mock(), mock.Mock()
1354 mock_process = mock.Mock(
1357 communicate=mock.Mock(side_effect=mock_communicate)
1360 return mock.Mock(
1361 __enter__=mock.Mock(return_value=mock_process),
1362 __exit__=mock.Mock(return_value=None)
1365 hardware = None if not has_hardware else mock.Mock(
1378 handler.get_hardware = mock.Mock(return_value=hardware)
1379 handler.options = mock.Mock(
1384 handler._get_serial_device = mock.Mock(side_effect=mock_get_serial)
1385 handler._create_command = mock.Mock(return_value=['dummy', 'command'])
1386 handler.run_custom_script = mock.Mock()
1387 handler._create_serial_connection = mock.Mock(
1390 handler.monitor_serial = mock.Mock()
1391 handler.terminate = mock.Mock(side_effect=mock_terminate)
1392 handler._update_instance_info = mock.Mock()
1393 handler._final_handle_actions = mock.Mock()
1394 handler.make_device_available = mock.Mock()
1397 harness = mock.Mock()
1399 with mock.patch('builtins.open', mock.mock_open(read_data='')), \
1400 mock.patch('subprocess.Popen', side_effect=mock_popen), \
1401 mock.patch('threading.Event', mock.Mock()), \
1402 mock.patch('threading.Thread', side_effect=mock_thread):
1414 mock.call('dummy pre script', mock.ANY)
1421 mock.call('dummy pre script', mock.ANY),
1422 mock.call('dummy post flash script', mock.ANY),
1423 mock.call('dummy post script', mock.ANY)
1462 return mock.Mock(
1463 cpu_times=mock.Mock(
1464 return_value=mock.Mock(
1471 with mock.patch('psutil.Process', mock_process):
1481 mock.PropertyMock(return_value=os.path.join('dummy_dir', '1')),
1487 mock.PropertyMock(return_value=os.path.join('dummy_dir', '2')),
1504 get_default_domain_mock = mock.Mock()
1506 domains_mock = mock.Mock(get_default_domain=get_default_domain_mock)
1507 from_file_mock = mock.Mock(return_value=domains_mock)
1513 with mock.patch('domains.Domains.from_file', from_file_mock):
1546 unlink_mock = mock.Mock()
1547 exists_mock = mock.Mock(return_value=exists_pid_fn)
1553 with mock.patch('os.unlink', unlink_mock), \
1554 mock.patch('os.path.exists', exists_mock):
1652 mocked_instance.add_missing_case_status = mock.Mock()
1699 unlink_mock = mock.Mock()
1700 exists_mock = mock.Mock(side_effect=mock_exists)
1701 mkfifo_mock = mock.Mock()
1707 with mock.patch('os.unlink', unlink_mock), \
1708 mock.patch('os.mkfifo', mkfifo_mock), \
1709 mock.patch('os.path.exists', exists_mock), \
1710 mock.patch('builtins.open', mock.mock_open()) as open_mock:
1714 mock.call('fifo.in', 'wb'),
1715 mock.call('fifo.out', 'rb', buffering=0),
1716 mock.call('log.file', 'wt'),
1746 unlink_mock = mock.Mock()
1747 kill_mock = mock.Mock(side_effect=mock_kill)
1752 out_fp = mock.Mock()
1753 in_fp = mock.Mock()
1754 log_out_fp = mock.Mock()
1756 with mock.patch('os.unlink', unlink_mock), \
1757 mock.patch('os.kill', kill_mock):
1765 unlink_mock.assert_has_calls([mock.call('fifo.in'), mock.call('fifo.out')])
1810 [mock.call('1\n'), mock.call('1\n')]
1820 [mock.call('1\n'), mock.call('1\n')]
1850 [mock.call('1\n'), mock.call('2\n'), mock.call('3\n'), mock.call('4\n')]
1860 [mock.call('1\n'), mock.call('2\n')]
1870 [mock.call('1\n'), mock.call('2\n'), mock.call('3\n'), mock.call('4\n')]
1906 type(mocked_instance.testsuite).timeout = mock.PropertyMock(return_value=timeout)
1912 handler.options = mock.Mock(timeout_multiplier=1)
1922 file_object = mock.mock_open(read_data=contents).return_value
1926 harness = mock.Mock(capture_coverage=capture_coverage, handle=print)
1927 type(harness).state = mock.PropertyMock(side_effect=harness_states)
1929 p = mock.Mock()
1930 p.poll = mock.Mock(
1934 mock_thread_get_fifo_names = mock.Mock(
1937 log_fp_mock = mock.Mock()
1939 out_fp_mock = mock.Mock()
1940 mock_thread_open_files = mock.Mock(
1943 mock_thread_close_files = mock.Mock()
1944 mock_thread_update_instance_info = mock.Mock()
1946 with mock.patch('time.time', side_effect=faux_timer.time), \
1947 mock.patch('builtins.open', new=mocked_open), \
1948 mock.patch('select.poll', return_value=p), \
1949 mock.patch('os.path.exists', return_value=True), \
1950 mock.patch('twisterlib.handlers.QEMUHandler._get_cpu_time',
1952 mock.patch('twisterlib.handlers.QEMUHandler._thread_get_fifo_names',
1954 mock.patch('twisterlib.handlers.QEMUHandler._thread_open_files',
1956 mock.patch('twisterlib.handlers.QEMUHandler._thread_close_files',
1958 mock.patch('twisterlib.handlers.QEMUHandler.' \
1975 mock.ANY,
2009 mock_process = mock.Mock(pid=0, returncode=1)
2010 mock_process.communicate = mock.Mock(
2011 return_value=(mock.Mock(), mock.Mock())
2013 mock_process.wait = mock.Mock(side_effect=mock_wait)
2021 return mock.Mock(
2022 __enter__=mock.Mock(return_value=mock_process),
2023 __exit__=mock.Mock(return_value=None),
2024 communicate=mock.Mock(return_value=(mock.Mock(), mock.Mock()))
2028 return mock.Mock()
2035 harness = mock.Mock(state=harness_state)
2041 handler.options = mock.Mock(
2046 handler.run_custom_script = mock.Mock(return_value=None)
2047 handler.make_device_available = mock.Mock(return_value=None)
2048 handler._final_handle_actions = mock.Mock(return_value=None)
2049 handler._create_command = mock.Mock(return_value=command)
2050 handler._set_qemu_filenames = mock.Mock(side_effect=mock_filenames)
2051 handler._get_sysbuild_build_dir = mock.Mock(return_value=sysbuild_build_dir)
2052 handler.terminate = mock.Mock()
2054 unlink_mock = mock.Mock()
2056 with mock.patch('subprocess.Popen', side_effect=mock_popen), \
2057 mock.patch('builtins.open', mock.mock_open(read_data='1')), \
2058 mock.patch('threading.Thread', side_effect=mock_thread), \
2059 mock.patch('os.path.exists', side_effect=mock_path_exists), \
2060 mock.patch('os.unlink', unlink_mock), \
2061 mock.patch('sys.stdout.isatty', return_value=isatty):