示例#1
0
    def test_script_mp_run(self, script_path):
        fake_device = Mock()
        test_queue = Mock()
        test_script = Python3(script_path)
        test_script.mp_run(test_queue, fake_device)

        test_queue.put.assert_called_once_with('script')
示例#2
0
 def test_script_mp_run_error(self, error_script_path):
     fake_device = Mock()
     test_queue = Mock()
     test_script = Python3(error_script_path)
     test_script.mp_run(test_queue, fake_device)
     assert test_queue.put.call_count == 2
     assert 'NotImplementedError' in str(test_queue.put.call_args_list)
     assert 'script' in str(test_queue.put.call_args_list[1][0])
示例#3
0
    def test_mp_logcat_regex_one_iteration(self, sleep, script_path):
        fake_device = Mock()
        fake_device.logcat_regex.side_effect = [False, True]
        test_queue = Mock()
        test_script = Python3(script_path)
        test_script.mp_logcat_regex(test_queue, fake_device, "Test")

        sleep.assert_called_once_with(1)
        test_queue.put.assert_called_once_with("logcat")
示例#4
0
 def test_script_error(self, error_script_path):
     fake_device = Mock()
     with pytest.raises(ScriptError) as expect_ex:
         Python3(error_script_path).run(fake_device)
     assert 'NotImplementedError' in str(expect_ex.value)
示例#5
0
 def test_script_run_logcat(self, script_path):
     fake_device = Mock()
     assert Python3(script_path,
                    logcat_regex='').run(fake_device) == 'logcat'
示例#6
0
 def test_script_run_timeout(self, script_path):
     fake_device = Mock()
     assert Python3(script_path, timeout=10).run(fake_device) == 'timeout'
示例#7
0
 def test_script_run_normal(self, script_path):
     fake_device = Mock()
     assert Python3(script_path).run(fake_device) == 'script'
示例#8
0
 def test_python3_execute_script(self, script_path):
     fake_device = Mock()
     assert Python3(script_path).execute_script(fake_device) == 'succes'
示例#9
0
 def test_python3_error_init(self, init_error_script_path):
     with pytest.raises(ImportError):
         Python3(init_error_script_path)