#NEWLINE# def test_version( self ) : #NEWLINE# #INDENT# '\n            Test to Common interface for obtaining the version\n            of installed packages.\n        ' #NEWLINE# with patch . object ( salt . utils , 'is_true' , return_value = True ) : #NEWLINE# #INDENT# mock = MagicMock ( return_value = { #NEWLINE# #INDENT# 'A' : 'B' , #NEWLINE# #UNINDENT# } ) #NEWLINE# with patch . dict ( pkg_resource . __salt__ , { #NEWLINE# #INDENT# 'pkg.list_pkgs' : mock , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# self . assertEqual ( pkg_resource . version ( 'A' ) , 'B' ) #NEWLINE# self . assertDictEqual ( pkg_resource . version ( ) , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# mock = MagicMock ( return_value = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# with patch . dict ( pkg_resource . __salt__ , { #NEWLINE# #INDENT# 'pkg.list_pkgs' : mock_next , #NEWLINE# #UNINDENT# } ) : #NEWLINE# #INDENT# with patch ( ( 'builtins.next' if six . PY3 else '__builtin__.next' ) ) as mock_next : #NEWLINE# #INDENT# mock_next . side_effect = StopIteration ( ) #NEWLINE# self . assertEqual ( pkg_resource . version ( 'A' ) , '' )