diff --git a/examples/windowmediaplayer.py b/examples/windowmediaplayer.py index a4cfa718e..c097da749 100644 --- a/examples/windowmediaplayer.py +++ b/examples/windowmediaplayer.py @@ -19,7 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -"Some automation of Windows Media player" +"""Some automation of Windows Media player""" from __future__ import unicode_literals from __future__ import print_function @@ -33,7 +33,6 @@ import os.path pywinauto_path = os.path.abspath(__file__) pywinauto_path = os.path.split(os.path.split(pywinauto_path)[0])[0] - import sys sys.path.append(pywinauto_path) from pywinauto import application diff --git a/pywinauto/controls/__init__.py b/pywinauto/controls/__init__.py index 18940426a..810c81802 100644 --- a/pywinauto/controls/__init__.py +++ b/pywinauto/controls/__init__.py @@ -19,9 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -"Controls package" - -__revision__ = "$Revision$" +"""Controls package""" from .HwndWrapper import GetDialogPropsFromHandle from .HwndWrapper import InvalidWindowHandle @@ -30,40 +28,5 @@ # import the control classes - this will register the classes they # contain -from .. import six from . import common_controls from . import win32_controls - -# -##==================================================================== -#def _unittests(): -# "Run some tests on the controls" -# from pywinauto import win32functions -# -# "do some basic testing" -# from pywinauto.findwindows import find_windows -# import sys -# -# if len(sys.argv) < 2: -# handle = win32functions.GetDesktopWindow() -# else: -# try: -# handle = int(eval(sys.argv[1])) -# -# except ValueError: -# -# handle = find_windows( -# title_re = "^" + sys.argv[1], class_name = "#32770", ) -# #visible_only = False) -# -# if not handle: -# print "dialog not found" -# sys.exit() -# -# -# props = GetDialogPropsFromHandle(handle) -# print len(props) -# #pprint(GetDialogPropsFromHandle(handle)) -# -#if __name__ == "__main__": -# _unittests() diff --git a/pywinauto/controls/common_controls.py b/pywinauto/controls/common_controls.py index 8a176c263..14282220a 100644 --- a/pywinauto/controls/common_controls.py +++ b/pywinauto/controls/common_controls.py @@ -203,8 +203,8 @@ def GetItemRect(self, item_index): # if it succeeded if not retval: - del remote_mem - raise RuntimeError("Did not succeed in getting rectangle") + del remote_mem + raise RuntimeError("Did not succeed in getting rectangle") rect = remote_mem.Read(rect) @@ -507,15 +507,15 @@ def GetSelectedCount(self): # commented out as we can get these strings from the header - # col = remote_mem.Read(col) + # col = remote_mem.Read(col) # # charData = ctypes.create_unicode_buffer(2000) # - # ret = remote_mem.Read(charData, col.pszText) + # ret = remote_mem.Read(charData, col.pszText) # - # self.Titles.append(charData.value) - # else: - # break + # self.Titles.append(charData.value) + # else: + # break @@ -1658,9 +1658,6 @@ def Select(self, tab): - - - #==================================================================== class _toolbar_button(object): "Wrapper around Toolbar button (TBBUTTONINFO) items" @@ -2153,16 +2150,16 @@ def CheckButton(self, button_identifier, make_checked, exact = True): # ExStyle = extendedStyle # ) # ) -# # if button.fsStyle & TBSTYLE_DROPDOWN == TBSTYLE_DROPDOWN and \ -# # (extendedStyle & TBSTYLE_EX_DRAWDDARROWS) != \ +# # if button.fsStyle & TBSTYLE_DROPDOWN == TBSTYLE_DROPDOWN and \ +# # (extendedStyle & TBSTYLE_EX_DRAWDDARROWS) != \ # # TBSTYLE_EX_DRAWDDARROWS: -# # props['Buttons'][-1]["DROPDOWNMENU"] = 1 +# # props['Buttons'][-1]["DROPDOWNMENU"] = 1 # # -# # self.SendMessage(WM_COMMAND, button.idCommand) +# # self.SendMessage(WM_COMMAND, button.idCommand) # # -# # print "Pressing", text.value -# # handle.SendMessage(TB_PRESSBUTTON, button.idCommand, 1) -# # handle.SendMessage(TB_PRESSBUTTON, button.idCommand, 0) +# # print "Pressing", text.value +# # handle.SendMessage(TB_PRESSBUTTON, button.idCommand, 1) +# # handle.SendMessage(TB_PRESSBUTTON, button.idCommand, 0) # # self._extra_texts.append(text.value) # @@ -2459,20 +2456,20 @@ class TrackbarWrapper(HwndWrapper.HwndWrapper): # # #---------------------------------------------------------------- -# def GetNumTicks(self): -# return self.SendMessage(win32defines.TBM_GETNUMTICS) +# def GetNumTicks(self): +# return self.SendMessage(win32defines.TBM_GETNUMTICS) # # #---------------------------------------------------------------- -# def GetPos(self): -# return self.SendMessage(win32defines.TBM_GETPOS) +# def GetPos(self): +# return self.SendMessage(win32defines.TBM_GETPOS) # # #---------------------------------------------------------------- -# def GetRangeMax(self): -# return self.SendMessage(win32defines.TBM_GETRANGEMAX) +# def GetRangeMax(self): +# return self.SendMessage(win32defines.TBM_GETRANGEMAX) # # #---------------------------------------------------------------- -# def GetRangeMin(self): -# return self.SendMessage(win32defines.TBM_GETRANGEMIN) +# def GetRangeMin(self): +# return self.SendMessage(win32defines.TBM_GETRANGEMIN) # # #---------------------------------------------------------------- # def GetToolTipsControl(self): @@ -2646,80 +2643,80 @@ def StepIt(self): ## ###==================================================================== ##class ComboBoxEx(Controls_Standard.ComboBox): -## #---------------------------------------------------------------- -## def __init__(self, hwndOrXML): -# Window.__init__(self, hwndOrXML) +## #---------------------------------------------------------------- +## def __init__(self, hwndOrXML): +# Window.__init__(self, hwndOrXML) ## -# if isinstance(hwndOrXML, (int, long)): -## comboCntrl = SendMessage( -## hwndOrXML, -## CBEM_GETCOMBOCONTROL, -## 0, -## 0) +# if isinstance(hwndOrXML, (int, long)): +## comboCntrl = SendMessage( +## hwndOrXML, +## CBEM_GETCOMBOCONTROL, +## 0, +## 0) ## -## print "--"*20, comboCntrl -## Controls_Standard.ComboBox.__init__(self, comboCntrl) -## print self.DroppedRect +## print "--"*20, comboCntrl +## Controls_Standard.ComboBox.__init__(self, comboCntrl) +## print self.DroppedRect ## ## ## -## droppedRect = win32structures.RECT() +## droppedRect = win32structures.RECT() ## -## SendMessage( -## self, -## CB_GETDROPPEDCONTROLRECT, -## 0, -## ctypes.byref(droppedRect)) +## SendMessage( +## self, +## CB_GETDROPPEDCONTROLRECT, +## 0, +## ctypes.byref(droppedRect)) ## -## props['DroppedRect'] = droppedRect +## props['DroppedRect'] = droppedRect # # # # # # -# # find out how many text items are in the combobox -# numItems = SendMessage( -# self, -# CB_GETCOUNT, -# 0, -# 0) +# # find out how many text items are in the combobox +# numItems = SendMessage( +# self, +# CB_GETCOUNT, +# 0, +# 0) # -# print "*"*20, numItems -## remote_mem = RemoteMemoryBlock(self) +# print "*"*20, numItems +## remote_mem = RemoteMemoryBlock(self) ## ## -## # get the text for each item in the combobox -## while True: -## item = COMBOBOXEXITEMW() +## # get the text for each item in the combobox +## while True: +## item = COMBOBOXEXITEMW() ## -## item.mask = CBEIF_TEXT -## item.cchTextMax = 4000 -## item.pszText = remote_mem.Address() + ctypes.sizeof(item) + 1 +## item.mask = CBEIF_TEXT +## item.cchTextMax = 4000 +## item.pszText = remote_mem.Address() + ctypes.sizeof(item) + 1 ## -## remote_mem.Write(item) +## remote_mem.Write(item) ## -## retval = SendMessage ( -## self, -## CBEM_GETITEMW, -## 0, -## remote_mem -## ) +## retval = SendMessage ( +## self, +## CBEM_GETITEMW, +## 0, +## remote_mem +## ) ## -## if retval: -## item = remote_mem.Read(item) +## if retval: +## item = remote_mem.Read(item) ## -## # Read the remote text string +## # Read the remote text string ## charData = ctypes.create_unicode_buffer(4000) -## remote_mem.Read(charData, item.pszText) -## self.Titles.append(charData.value) -## else: -## break +## remote_mem.Read(charData, item.pszText) +## self.Titles.append(charData.value) +## else: +## break ## # -# else: +# else: # -# # get the dropped Rect form -# droppedRect = XMLToRect(hwndOrXML.find("DROPPEDRECT")) -# props['DroppedRect'] = droppedRect +# # get the dropped Rect form +# droppedRect = XMLToRect(hwndOrXML.find("DROPPEDRECT")) +# props['DroppedRect'] = droppedRect diff --git a/pywinauto/controls/win32_controls.py b/pywinauto/controls/win32_controls.py index f2b849573..f49fc0813 100644 --- a/pywinauto/controls/win32_controls.py +++ b/pywinauto/controls/win32_controls.py @@ -237,7 +237,6 @@ def _get_multiple_text_items(wrapper, count_msg, item_len_msg, item_get_msg): if six.PY3: texts.append(text.value.replace('\u200e', '')) else: - import locale texts.append(text.value.decode(locale.getpreferredencoding(), 'ignore').replace('?', '')) return texts diff --git a/pywinauto/findbestmatch.py b/pywinauto/findbestmatch.py index e28c73ec7..cf8e338bb 100644 --- a/pywinauto/findbestmatch.py +++ b/pywinauto/findbestmatch.py @@ -75,7 +75,7 @@ def _get_match_ratios(texts, match_against): best_ratio = 0 best_text = '' - global cache + global _cache for text in texts: diff --git a/pywinauto/unittests/test_XMLHelpers.py b/pywinauto/unittests/test_XMLHelpers.py index 979c45f4c..02459f4ca 100644 --- a/pywinauto/unittests/test_XMLHelpers.py +++ b/pywinauto/unittests/test_XMLHelpers.py @@ -21,8 +21,6 @@ """Module containing tests for XMLHelpers Module""" -__revision__ = "$Revision: 236 $" - import sys sys.path.append(".") diff --git a/pywinauto/unittests/test_win32functions.py b/pywinauto/unittests/test_win32functions.py index 2ae57f44b..fb759a2a8 100644 --- a/pywinauto/unittests/test_win32functions.py +++ b/pywinauto/unittests/test_win32functions.py @@ -1,4 +1,5 @@ # GUI Application automation and testing library +# Copyright (C) 2015 Intel Corporation # Copyright (C) 2007 Mark Mc Mahon # # This library is free software; you can redistribute it and/or @@ -18,9 +19,7 @@ # Suite 330, # Boston, MA 02111-1307 USA -"Tests for win32functions.py" - -__revision__ = "$Revision: 234 $" +"""Tests for win32functions.py""" import unittest @@ -28,8 +27,6 @@ sys.path.append(".") from pywinauto.win32functions import * -#import struct - class Win32FunctionsTestCases(unittest.TestCase): "Unit tests for the win32function methods"