Skip to content

Commit

Permalink
Avoid overwriting built-in functions/attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
vasily-v-ryabov committed Aug 3, 2015
1 parent e12b75f commit 6df1407
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 41 deletions.
16 changes: 8 additions & 8 deletions pywinauto/clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,33 @@ def GetClipboardFormats():
win32clipboard.OpenClipboard()

available_formats = []
format = 0
current_format = 0
while True:
# retrieve the next format
format = win32clipboard.EnumClipboardFormats(format)
current_format = win32clipboard.EnumClipboardFormats(current_format)

# stop enumerating because all formats have been
# retrieved
if not format:
if not current_format:
break

available_formats.append(format)
available_formats.append(current_format)

win32clipboard.CloseClipboard()

return available_formats


#====================================================================
def GetFormatName(format):
def GetFormatName(format_id):
"Get the string name for a format value"

# standard formats should not be passed to GetClipboardFormatName
if format in _standard_formats:
return _standard_formats[format]
if format_id in _standard_formats:
return _standard_formats[format_id]

win32clipboard.OpenClipboard()
format_name = win32clipboard.GetClipboardFormatName(format)
format_name = win32clipboard.GetClipboardFormatName(format_id)
win32clipboard.CloseClipboard()

return format_name
Expand Down
8 changes: 0 additions & 8 deletions pywinauto/findbestmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@
#levenshtein_distance = ctypes.cdll.levenshtein.levenshtein_distance
#levenshtein_distance = ldistance.distance

# need to use sets.Set for python 2.3 compatability
# but 2.6 raises a deprecation warning about sets module
try:
set
except NameError:
import sets
set = sets.Set

find_best_control_match_cutoff = .6

#====================================================================
Expand Down
4 changes: 2 additions & 2 deletions pywinauto/handleprops.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def is64bitprocess(process_id):
#=========================================================================
def is64bitbinary(filename):
import win32file
type = win32file.GetBinaryType(filename)
return type != win32file.SCS_32BIT_BINARY
binary_type = win32file.GetBinaryType(filename)
return binary_type != win32file.SCS_32BIT_BINARY

#=========================================================================
def clientrect(handle):
Expand Down
11 changes: 1 addition & 10 deletions pywinauto/tests/repeatedhotkey.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# GUI Application automation and testing library
# Copyright (C) 2015 Intel Corporation
# Copyright (C) 2010 Mark Mc Mahon
#
# This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -68,15 +69,6 @@
"""

testname = "RepeatedHotkey"
__revision__ = "$Revision$"

# need to use sets.Set for python 2.3 compatability
# but 2.6 raises a deprecation warning about sets module
try:
set
except NameError:
import sets
set = sets.Set

from pywinauto.win32defines import SS_NOPREFIX

Expand Down Expand Up @@ -245,4 +237,3 @@ def ImplementsHotkey(win):


RepeatedHotkeyTest.TestsMenus = True

28 changes: 15 additions & 13 deletions pywinauto/unittests/test_SendKeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@

# Fix Python 2.x.
if six.PY2:
input = raw_input
input_func = raw_input
else:
input_func = input


class SendKeysTests(unittest.TestCase):
Expand All @@ -79,7 +81,7 @@ def __run_NormalCharacters_with_options(self, **args):
continue

SendKeys(chr(i) + "{ENTER}", pause = .001, **args)
received = input()
received = input_func()

self.assertEquals(i, ord(received))

Expand All @@ -95,13 +97,13 @@ def testNormalWithoutSpaces(self):
def testSpaceWithSpaces(self):
"Make sure that with spaces option works"
SendKeys(" \t \t {ENTER}", pause = .001, with_spaces = True)
received = input()
received = input_func()
self.assertEquals(" ", received)

def testSpaceWithoutSpaces(self):
"Make sure that with spaces option works"
SendKeys(" \t \t {ENTER}", pause = .001, with_spaces = False)
received = input()
received = input_func()
self.assertEquals("", received)


Expand All @@ -117,20 +119,20 @@ def testNormalWithoutTabs(self):
def testTabWithTabs(self):
"Make sure that with spaces option works"
SendKeys("\t \t \t{ENTER}", pause = .1, with_tabs = True)
received = input()
received = input_func()
self.assertEquals("\t\t\t", received)

def testTabWithoutTabs(self):
"Make sure that with spaces option works"
SendKeys("\t a\t b\t{ENTER}", pause = .1, with_tabs = False)
received = input()
received = input_func()
self.assertEquals("ab", received)


def testTab(self):
"Make sure that with spaces option works"
SendKeys("{TAB} {TAB} {ENTER}", pause = .3)
received = input()
received = input_func()
self.assertEquals("\t\t", received)


Expand All @@ -147,19 +149,19 @@ def testNormalWithoutNewlines(self):
def testNewlinesWithNewlines(self):
"Make sure that with spaces option works"
SendKeys("\t \t \t a~\tb\nc{ENTER}", pause = .1, with_newlines = True)
received = input()
received = input_func()
self.assertEquals("a", received)

received = input()
received = input_func()
self.assertEquals("b", received)

received = input()
received = input_func()
self.assertEquals("c", received)

def testNewlinesWithoutNewlines(self):
"Make sure that with spaces option works"
SendKeys("\t \t \t\na{ENTER}", pause = .01, with_newlines = False)
received = input()
received = input_func()
self.assertEquals("a", received)


Expand All @@ -175,7 +177,7 @@ def testANSIExtendedCharacters(self):
else:
c = char.decode('cp850')
SendKeys(c + "{ENTER}", pause = .01)
received = input()
received = input_func()

if str(char) == received:
matched += 1
Expand All @@ -188,7 +190,7 @@ def testANSIExtendedCharacters(self):
def testCharsThatMustBeEscaped(self):
"Make sure that escaping characters works"
SendKeys("{%}{^}{+}{(}{)}{{}{}}{~}{ENTER}")
received = input()
received = input_func()
self.assertEquals("%^+(){}~", received)


Expand Down

0 comments on commit 6df1407

Please sign in to comment.