Пример #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)