示例#1
0
    def test_script_mp_run(self, script_path):
        fake_device = Mock()
        test_queue = Mock()
        test_script = Python2(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 = Python2(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_logcat(self):
     self.assertEqual(
         Python2(self.file.name, logcat_regex='').run(self.device),
         'logcat')
示例#4
0
 def test_timeout(self):
     self.assertEqual(
         Python2(self.file.name, timeout=10).run(self.device), 'timeout')
示例#5
0
 def test_normal(self):
     self.assertEqual(Python2(self.file.name).run(self.device), 'script')
示例#6
0
 def test_script_error(self, error_script_path):
     fake_device = Mock()
     with pytest.raises(ScriptError) as expect_ex:
         Python2(error_script_path).run(fake_device)
     assert 'NotImplementedError' in str(expect_ex.value)
示例#7
0
 def test_script_run_logcat(self, script_path):
     fake_device = Mock()
     assert Python2(script_path, logcat_regex='').run(fake_device) == 'logcat'
示例#8
0
 def test_script_run_timeout(self, script_path):
     fake_device = Mock()
     assert Python2(script_path, timeout=10).run(fake_device) == 'timeout'
示例#9
0
 def test_script_run_normal(self, script_path):
     fake_device = Mock()
     assert Python2(script_path).run(fake_device) == 'script'
示例#10
0
 def test_python2_execute_script(self, script_path):
     fake_device = Mock()
     assert Python2(script_path).execute_script(fake_device) == 'succes'
示例#11
0
 def test_python2_error_init(self, init_error_script_path):
     with pytest.raises(ImportError):
         Python2(init_error_script_path)