jenkins-bot has submitted this change and it was merged.
Change subject: Skip UI tests on Appveyor builds
......................................................................
Skip UI tests on Appveyor builds
Added better detection and error reporting of pywin32 and pywinauto
loading sequence.
Use Python 3 compatible repositories for pywin32 and pywinauto
in setup.py
The pywinauto tests operate, however they always fail on due to
differences in expected and actual output.
Bug: T97913
Change-Id: I76ef4d222f9d907789bc55a38394be75c437b198
---
M .appveyor.yml
M setup.py
M tests/ui_tests.py
3 files changed, 68 insertions(+), 28 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.appveyor.yml b/.appveyor.yml
index c91b550..64f3cf1 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -44,6 +44,7 @@
- echo console_encoding = 'utf8' >>
"%PYWIKIBOT2_DIR%\\user-config.py"
- echo transliteration_target = None >>
"%PYWIKIBOT2_DIR%\\user-config.py"
+ - set PYSETUP_TEST_NO_UI=1
- "%WITH_COMPILER% %PYTHON%\\python setup.py test"
artifacts:
diff --git a/setup.py b/setup.py
index a33928e..cbf08fa 100644
--- a/setup.py
+++ b/setup.py
@@ -54,8 +54,15 @@
if sys.platform.startswith('linux'):
script_deps['script_wui.py'] = [irc_dep, 'lunatic-python',
'crontab']
+# The main pywin32 repository contains a Python 2 only setup.py with a small
+# wrapper setup3.py for Python 3.
+#
http://pywin32.hg.sourceforge.net:8000/hgroot/pywin32/pywin32
+# The main pywinauto repository doesnt support Python 3.
+# The repositories used below have a Python 3 compliant setup.py
dependency_links = [
'git+https://github.com/AlereDevices/lunatic-python.git#egg=lunatic-python',
+ 'hg+https://bitbucket.org/TJG/pywin32#egg=pywin32',
+ 'git+https://github.com/vasily-v-ryabov/pywinauto-64#egg=pywinauto',
]
if sys.version_info[0] == 2:
@@ -91,12 +98,20 @@
# when trying to build the C modules.
dependencies += extra_deps['mwparserfromhell']
-# setup can't detect or install pywin32, which pywinauto depends on.
-# appveyor builds do not install pywin32
-if os.name == 'nt':
+# Some of the ui_tests depend on accessing the console window's menu
+# to set the console font and copy and paste, achieved using pywinauto
+# which depends on pywin32.
+# These tests may be disabled because pywin32 depends on VC++, is time
+# comsuming to build, and the console window cant be accessed during appveyor
+# builds.
+# Microsoft makes available a compiler for Python 2.7
+#
http://www.microsoft.com/en-au/download/details.aspx?id=44266
+# If you set up your own compiler for Python 3, on 3.3 two demo files
+# packaged with pywin32 may fail. Remove com/win32com/demos/ie*.py
+if os.name == 'nt' and os.environ.get('PYSETUP_TEST_NO_UI', '0')
!= '1':
# FIXME: tests/ui_tests.py suggests pywinauto 0.4.2
# which isnt provided on pypi.
- test_deps += ['pywinauto>=0.4.0']
+ test_deps += ['pywin32', 'pywinauto>=0.4.0']
extra_deps.update(script_deps)
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index d44d19c..811dfe2 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -28,21 +28,39 @@
__version__ = '$Id$'
+import inspect
+import io
import logging
import os
+import subprocess
import sys
import time
-import io
-try:
- import pywinauto
-except ImportError:
- pywinauto = None
+if os.name == "nt":
+ from multiprocessing.managers import BaseManager
+ import threading
+
+ try:
+ import win32api
+ except ImportError:
+ win32api = None
+
+ try:
+ import pywinauto
+ except ImportError:
+ pywinauto = None
+
+ try:
+ import win32clipboard
+ except ImportError:
+ win32clipboard = None
import pywikibot
+
from pywikibot.bot import (
ui, DEBUG, VERBOSE, INFO, STDOUT, INPUT, WARNING, ERROR, CRITICAL
)
+
from tests.utils import unittest
if sys.version_info[0] > 2:
@@ -79,23 +97,18 @@
if os.name == "nt":
- from multiprocessing.managers import BaseManager
- import threading
class pywikibotWrapper(object):
"""pywikibot wrapper class."""
def init(self):
- import pywikibot # noqa
pywikibot.version._get_program_dir()
def output(self, *args, **kwargs):
- import pywikibot # noqa
return pywikibot.output(*args, **kwargs)
def request_input(self, *args, **kwargs):
- import pywikibot # noqa
self.input = None
def threadedinput():
@@ -108,11 +121,9 @@
return self.input
def set_config(self, key, value):
- import pywikibot # noqa
setattr(pywikibot.config, key, value)
def set_ui(self, key, value):
- import pywikibot # noqa
setattr(pywikibot.ui, key, value)
def cls(self):
@@ -503,28 +514,46 @@
def setUpClass(cls):
if os.name != 'nt':
raise unittest.SkipTest('requires Windows console')
+ if not win32api:
+ raise unittest.SkipTest('requires Windows package pywin32')
+ if not win32clipboard:
+ raise unittest.SkipTest('requires Windows package win32clipboard')
if not pywinauto:
raise unittest.SkipTest('requires Windows package pywinauto')
+ try:
+ # pywinauto 0.5.0
+ cls._app = pywinauto.Application()
+ except AttributeError as e1:
+ try:
+ cls._app = pywinauto.application.Application()
+ except AttributeError as e2:
+ raise unittest.SkipTest('pywinauto Application failed: %s\n%s'
+ % (e1, e2))
super(WindowsTerminalTestCase, cls).setUpClass()
@classmethod
def setUpProcess(cls, command):
- import subprocess
si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESTDHANDLES
cls._process = subprocess.Popen(command,
creationflags=subprocess.CREATE_NEW_CONSOLE)
- cls._app = pywinauto.application.Application()
cls._app.connect_(process=cls._process.pid)
# set truetype font (Lucida Console, hopefully)
try:
- cls._app.window_().TypeKeys('% {UP}{ENTER}^L{HOME}L{ENTER}',
with_spaces=True)
- except:
- # occurs if pywinauto is installed without pywin32.
- raise unittest.SkipTest('Windows package pywinauto not functional; '
- 'maybe pywin32 isnt installed')
+ window = cls._app.window_()
+ except Exception as e:
+ cls.tearDownProcess()
+ raise unittest.SkipTest('Windows package pywinauto could not locate
window: %r'
+ % e)
+
+ try:
+ window.TypeKeys('% {UP}{ENTER}^L{HOME}L{ENTER}', with_spaces=True)
+ except Exception as e:
+ cls.tearDownProcess()
+ raise unittest.SkipTest('Windows package pywinauto could not use window
TypeKeys: %r'
+ % e)
@classmethod
def tearDownProcess(cls):
@@ -552,15 +581,11 @@
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()
@@ -582,7 +607,6 @@
@classmethod
def setUpClass(cls):
super(TestWindowsTerminalUnicode, cls).setUpClass()
- import inspect
fn = inspect.getfile(inspect.currentframe())
cls.setUpProcess(['python', 'pwb.py', fn,
'--run-as-slave-interpreter'])
--
To view, visit
https://gerrit.wikimedia.org/r/205575
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I76ef4d222f9d907789bc55a38394be75c437b198
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>