mirror of
https://github.com/clearlinux/autospec.git
synced 2026-11-26 15:46:37 +00:00
Add new test for _process_build_log
Adds the first example test to _process_build_log verifying it can handle a bad patch. Signed-off-by: William Douglas <william.douglas@intel.com>
This commit is contained in:
committed by
William Douglas
parent
a62a849262
commit
a16ede7440
+25
-1
@@ -2,7 +2,8 @@ import subprocess
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
import unittest.mock
|
||||
from unittest.mock import MagicMock, mock_open, patch
|
||||
|
||||
import util
|
||||
|
||||
|
||||
@@ -64,5 +65,28 @@ class TestUtil(unittest.TestCase):
|
||||
self.assertTrue(util.binary_in_path('testbin'))
|
||||
self.assertEqual(util.os_paths, [tmpd])
|
||||
|
||||
def test__process_build_log_bad_patch(self):
|
||||
"""
|
||||
Test _process_build_log with a bad patch
|
||||
"""
|
||||
def isfile_mock(_):
|
||||
return True
|
||||
isfile_backup = util.os.path.isfile
|
||||
util.os.path.isfile = isfile_mock
|
||||
call_backup = util.call
|
||||
util.call = MagicMock()
|
||||
open_name = 'util.open_auto'
|
||||
content = "Patch #1 (bad.patch):\nHunk #1 FAILED at 1."
|
||||
m_open = mock_open(read_data=content)
|
||||
with patch(open_name, m_open, create=True):
|
||||
util._process_build_log('filename')
|
||||
|
||||
util.os.path.isfile = isfile_backup
|
||||
mock_call = util.call
|
||||
util.call = call_backup
|
||||
self.assertTrue(len(mock_call.mock_calls) == 3)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(buffer=True)
|
||||
|
||||
Reference in New Issue
Block a user