コード例 #1
0
ファイル: test_core.py プロジェクト: simodalla/pygmount
 def test_run_command_with_check_output_function(
         self, mock_subprocess):
     check_output = Mock()
     check_output.__name__ = 'check_output'
     mock_subprocess.check_output = check_output
     run_command(self.command)
     check_output.assert_called_once_with(
         self.command, stderr=mock_subprocess.STDOUT, shell=True)
コード例 #2
0
ファイル: test_core.py プロジェクト: simodalla/pygmount
    def test_run_command_with_check_call_function(
            self, mock_subprocess):
        mock_subprocess.check_call.__name__ = 'check_call'
        if 'check_output' in dir(mock_subprocess):
            mock_subprocess.check_output = mock_subprocess.check_call
        run_command(self.command)

        mock_subprocess.check_call.assert_called_once_with(
            self.command, stderr=mock_subprocess.STDOUT, shell=True)
コード例 #3
0
ファイル: test_core.py プロジェクト: simodalla/pygmount
 def test_run_command_in_check_output_occours_exception(
         self, mock_subprocess):
     check_output = Mock()
     mock_subprocess.CalledProcessError = subprocess.CalledProcessError
     check_output.side_effect = subprocess.CalledProcessError(1,
                                                              self.command)
     result = run_command(self.command)
     self.assertEqual(result[0], 1)
     self.assertIsNone(result[1])
コード例 #4
0
ファイル: test_core.py プロジェクト: simodalla/pygmount
 def test_run_command_check_call_return_tuple(
         self, mock_subprocess):
     mock_subprocess.check_call.__name__ = 'check_call'
     mock_subprocess.check_call.return_value = 0
     if 'check_output' in dir(mock_subprocess):
         mock_subprocess.check_output = mock_subprocess.check_call
     result = run_command(self.command)
     self.assertEqual(result[0], 0)
     self.assertIsNone(result[1])
コード例 #5
0
ファイル: test_core.py プロジェクト: simodalla/pygmount
 def test_run_command_check_output_return_tuple(
         self, mock_subprocess):
     check_output = Mock()
     check_output.__name__ = 'check_output'
     check_output.return_value = 'command output'
     mock_subprocess.check_output = check_output
     result = run_command(self.command)
     self.assertEqual(result[0], 0)
     self.assertEqual(result[1], check_output.return_value)
コード例 #6
0
ファイル: test_core.py プロジェクト: simodalla/pygmount
 def test_run_command_in_check_output_occours_exception(
         self, mock_subprocess):
     mock_subprocess.CalledProcessError = subprocess.CalledProcessError
     mock_subprocess.check_call.side_effect = subprocess.CalledProcessError(
         1, self.command)
     if 'check_output' in dir(mock_subprocess):
         mock_subprocess.check_output = mock_subprocess.check_call
     result = run_command(self.command)
     self.assertEqual(result[0], 1)
     self.assertIsNone(result[1])