#NEWLINE# @ mock . patch ( 'six.moves.builtins.open' ) #NEWLINE# def test__read_params_from_file( self , open_mock ) : #NEWLINE# #INDENT# kernel_line = 'api-url=http://localhost:9999 baz foo=bar\n' #NEWLINE# open_mock . return_value . __enter__ = ( lambda s : s ) #NEWLINE# open_mock . return_value . __exit__ = mock . Mock ( ) #NEWLINE# read_mock = open_mock . return_value . read #NEWLINE# read_mock . return_value = kernel_line #NEWLINE# params = utils . _read_params_from_file ( 'file-path' ) #NEWLINE# open_mock . assert_called_once_with ( 'file-path' ) #NEWLINE# read_mock . assert_called_once_with ( ) #NEWLINE# self . assertEqual ( 'http://localhost:9999' , params [ 'api-url' ] ) #NEWLINE# self . assertEqual ( 'bar' , params [ 'foo' ] ) #NEWLINE# self . assertFalse ( ( 'baz' in params ) )