jenkins-bot has submitted this change and it was merged.
Change subject: Delay import of win32clipboard ......................................................................
Delay import of win32clipboard
Under python 2.7.8 on Windows, the default test loader for 'tests' tries to instantiate a module for each file called '*_tests.py', which fails for the module 'ui_tests' when pywin32 is not installed. This causes a backtrace in setup.py before testing commences. ui_tests is not part of the normal test suite; instead of testing, it prints a message saying it must be run outside of the test suite.
pywin32 does not appear easy to set as a test dependency, as setup fails to find a suitable egg to build, and pywin32 doesnt provide a pypi package, wheel binary packages, etc.
Moving the import to the code which uses win32clipboard allows the module to be instantiated, so it can report a test skip message during testing.
This change allows the tests to be run on MS Windows without pywin32 or pywinauto installed.
Bug: 68847
Change-Id: I507acbde9f682b9a92a902e9ce22a8d6a64ca583 --- M tests/ui_tests.py 1 file changed, 4 insertions(+), 1 deletion(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/ui_tests.py b/tests/ui_tests.py index c072d32..991460f 100644 --- a/tests/ui_tests.py +++ b/tests/ui_tests.py @@ -44,7 +44,6 @@ if os.name == "nt": from multiprocessing.managers import BaseManager import threading - import win32clipboard
class pywikibotWrapper(object): def init(self): @@ -395,11 +394,15 @@ time.sleep(0.01)
def setclip(self, text): + import win32clipboard + win32clipboard.OpenClipboard() win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, unicode(text)) win32clipboard.CloseClipboard()
def getclip(self): + import win32clipboard + win32clipboard.OpenClipboard() data = win32clipboard.GetClipboardData(win32clipboard.CF_UNICODETEXT) win32clipboard.CloseClipboard()
pywikibot-commits@lists.wikimedia.org