@ -1785,6 +1785,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
input_api . tbr = False
input_api . dry_run = None
input_api . python_executable = ' pyyyyython '
input_api . python3_executable = ' pyyyyython3 '
input_api . platform = sys . platform
input_api . cpu_count = 2
input_api . time = time
@ -3046,29 +3047,33 @@ the current line as well!
def testCannedCheckVPythonSpec ( self ) :
change = presubmit . Change ( ' a ' , ' b ' , self . fake_root_dir , None , 0 , 0 , None )
input_api = self . MockInputApi ( change , False )
affected_filenames = [ ' /path1/to/.vpython ' , ' /path1/to/.vpython3 ' ]
affected_files = [ ]
affected_file = mock . MagicMock ( presubmit . GitAffectedFile )
affected_file . AbsoluteLocalPath . return_value = ' /path1/to/.vpython '
input_api . AffectedTestableFiles . return_value = [ affected_file ]
for filename in affected_filenames :
affected_file = mock . MagicMock ( presubmit . GitAffectedFile )
affected_file . AbsoluteLocalPath . return_value = filename
affected_files . append ( affected_file )
input_api . AffectedTestableFiles . return_value = affected_files
commands = presubmit_canned_checks . CheckVPythonSpec (
input_api , presubmit . OutputApi )
self . assertEqual ( len ( commands ) , 1 )
self . assertEqual ( commands [ 0 ] . name , ' Verify /path1/to/.vpython ' )
self . assertEqual ( commands [ 0 ] . cmd , [
' vpython ' ,
' -vpython-spec ' , ' /path1/to/.vpython ' ,
' -vpython-tool ' , ' verify '
] )
self . assertDictEqual (
commands [ 0 ] . kwargs ,
{
' stderr ' : input_api . subprocess . STDOUT ,
' stdout ' : input_api . subprocess . PIPE ,
' stdin ' : input_api . subprocess . PIPE ,
} )
self . assertEqual ( commands [ 0 ] . message , presubmit . OutputApi . PresubmitError )
self . assertIsNone ( commands [ 0 ] . info )
self . assertEqual ( len ( commands ) , len ( affected_filenames ) )
for i in range ( 0 , len ( commands ) ) :
self . assertEqual ( commands [ i ] . name , ' Verify ' + affected_filenames [ i ] )
self . assertEqual ( commands [ i ] . cmd , [
input_api . python3_executable , ' -vpython-spec ' , affected_filenames [ i ] ,
' -vpython-tool ' , ' verify '
] )
self . assertDictEqual (
commands [ 0 ] . kwargs , {
' stderr ' : input_api . subprocess . STDOUT ,
' stdout ' : input_api . subprocess . PIPE ,
' stdin ' : input_api . subprocess . PIPE ,
} )
self . assertEqual ( commands [ 0 ] . message , presubmit . OutputApi . PresubmitError )
self . assertIsNone ( commands [ 0 ] . info )
class ThreadPoolTest ( unittest . TestCase ) :