Merge lp://staging/~coreygoldberg/window-mocker/py3 into lp://staging/window-mocker
- py3
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Thomi Richards |
Approved revision: | 45 |
Merged at revision: | 24 |
Proposed branch: | lp://staging/~coreygoldberg/window-mocker/py3 |
Merge into: | lp://staging/window-mocker |
Diff against target: |
657 lines (+285/-74) 13 files modified
bin/window-mocker (+7/-6) debian/control (+25/-1) debian/rules (+9/-4) po/window-mocker.pot (+1/-1) setup.py (+1/-2) tests/test_app_functional.py (+24/-17) tests/test_plugins.py (+26/-10) tests/test_testapp_modlue_functions.py (+6/-5) windowmocker/__init__.py (+1/-4) windowmocker/plugins/__init__.py (+36/-18) windowmocker/plugins/base.py (+2/-3) windowmocker/plugins/qt4.py (+2/-3) windowmocker/plugins/qt5.py (+145/-0) |
To merge this branch: | bzr merge lp://staging/~coreygoldberg/window-mocker/py3 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thomi Richards (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+196978@code.staging.launchpad.net |
Commit message
python3 compatibility, Qt5 plugin
Description of the change
- ported to py2/py3 compatible
- using Qt5 plugin when running under Python3
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Martin Pitt (pitti) wrote : | # |
Note that io.StringIO insists on writing unicode objects only, so it does behave differently than StringIO.StringIO in Python 2.7. If window-mocker carefully converts everythign that's fine, but doing so will break the Python 3 support. So far I must say I avoid io.StringIO in code that supports both py 2 and 3 as it makes the code quite ugly (lots of "if sys.version" checks). But YMMV.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:25
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Corey Goldberg (coreygoldberg) wrote : | # |
> so just import io.StringIO every time.
this is problematic due to Unicode handling.
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
> > so just import io.StringIO every time.
>
> this is problematic due to Unicode handling.
Hang on, it should make your life easier, not harder :)
Python 3 code needs clear separation of unicode vs byte strings. TBH, your python2 code should as well. If you want to deal with bytes, you can import 'io.BytesIO' instead. In my experience, using the older StringIO.StringIO class leads to problems down the line, since the behavior is remarkably different depending on what version of python you're running.
I guess if you're maintaining the code then that's fine, but I think this is going to cause you problems down the line :)
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
290 +
291 +
292 +
Too much whitespace (PEP8) :)
190 +# use Qt4 plugin for Python2, Qt5 plugin for Python3
191 +if sys.version_info[0] < 3:
192 + from windowmocker.
193 +else:
194 + from windowmocker.
Just thinking about our upgrade strategy here... If we do this, then the autopilot tests will need to be duplicated - one set of tests against Qt4, and another against Qt5 (because the introspection tree will be different - please correct me if I'm wrong here).
The Qt4 plugin should be importable in both python2 and python3, and should remain the default plugin.
The Qt5 plugin is only importable in python3, so we should make that plugin selectable, but only in python3 land.
Then we can port the autopilot tests that use window-mocker over, and we can explicitly ask for the Qt5 plugin, and either skip the tests in py2, or re-write them to work in py2/Qt4 as well.
However, following the above strategy will mean we don't break the AP tests once this gets merged.
- 26. By Corey Goldberg
-
update debian control
- 27. By Corey Goldberg
-
make qt4 default plugin
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:27
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 28. By Corey Goldberg
-
use io.StringIO
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:28
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Hi Corey,
There's still a few problems here. I grabbed your branch and built the package, but:
1) It only builds a python-windowmocker package, so there's no way to build & install the python3 variant.
2) If I run it from the source directly with:
PYTHONPATH=`pwd` python3 bin/window-mocker
then I get some python3 incompatibilities:
Traceback (most recent call last):
File "bin/window-
main()
File "bin/window-
application = create_
File "/home/
if not isinstance(
NameError: global name 'basestring' is not defined
These two issues prevent me from testing this further. Please let me know once these have been fixed and I can look at it again.
- 29. By Corey Goldberg
-
fixed py3 package
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:29
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 30. By Corey Goldberg
-
wrong package name
- 31. By Corey Goldberg
-
changed version in setup
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:30
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:31
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 32. By Corey Goldberg
-
merged debian pybuild
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:32
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 33. By Corey Goldberg
-
pyqt5 for py3 only
- 34. By Corey Goldberg
-
fixed d/rules
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:33
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:34
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 35. By Corey Goldberg
-
delay import of pyqt
- 36. By Corey Goldberg
-
fix delayed import of pyqt
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:35
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:36
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 37. By Corey Goldberg
-
added register_
named_plugin - 38. By Corey Goldberg
-
fixed plugins import
- 39. By Corey Goldberg
-
removed commented import
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:38
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:39
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 40. By Corey Goldberg
-
added unit tests for plugins
- 41. By Corey Goldberg
-
fixed d/rules for copy
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:40
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:39
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:41
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
bzr branch lp:~coreygoldberg/window-mocker/py3
cd py3
bzr bd
sudo dpkg -i ../build-area/*.deb
Does not work, because the .desktop files collide. You need to fix them like you had to fix the executable scripts.
Please make sure that, at a minimum, you can build the packages, install them, and the installed executables work before resubmitting for a review.
- 42. By Corey Goldberg
-
fixed shadowed py3 files
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:42
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Corey Goldberg (coreygoldberg) wrote : | # |
packages build now.
note.. when running `window-mocker`, i get the following output to console:
"No handlers could be found for logger "windowmocker.
when running `window-mocker3`, I don't get that debug output.
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Hi Corey,
Selecting the Qt5 plugin doesn't work. I expect:
window-mocker3 -t Qt4
to launch a Qt4 window, and:
window-mocker3 -t Qt5
to launch a Qt5 window.
At the moment they both launch a Qt4 window.
- 43. By Corey Goldberg
-
fixes for calling plugin
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:43
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Hi,
The latest revision includes several defects:
1) Running 'window-mocker' just produces an error and exits:
$ window-mocker
ERROR:windowmoc
Error: Unable to process request: Type name '<function get_default_
2) Running 'window-mocker3' produces similar errors:
$ window-mocker3
ERROR:windowmoc
Error: Unable to process request: Type name '<function get_default_
For both points 1) and 2), the desired behavior is that it should just open the window with the default plugin (qt4 in both cases).
3) Running 'window-mocker -h' lists the 'Qt5' plugin as an available option, but that's incorrect - Qt5 is not available in python 2. If you try and actually run it in this configuration, it crashes:
$ window-mocker -t Qt5
Traceback (most recent call last):
File "/usr/bin/
main()
File "/usr/bin/
application = create_
File "/usr/lib/
app_instance = app_plugin(data)
File "/usr/lib/
from windowmocker.
File "/usr/lib/
from PyQt5 import QtCore, QtWidgets
ImportError: No module named PyQt5
The Qt4 plugin should not be listed as an option in python2.
4) Running 'window-mocker3 -t Qt5' does indeed produce a Qt5 window (yay!), but closing that window causes window-mocker3 to crash (segfault, in fact, which is impressive, for a python application).
Given that these regressed, it's probably a good idea to add functional tests for all these issues before fixing them.
- 44. By Corey Goldberg
-
fixed get_default_
plugin_ name
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:44
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 45. By Corey Goldberg
-
fixes
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:45
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Barry Warsaw (barry) wrote : | # |
Apologies for not seeing this mp first, but I have a competing mp:
https:/
I'll take a look at Corey's branch and see if mine is missing anything. I don't have much of an opinion about PyQt4/PyQt5, but I have a strong opinion that window-mocker should only be Python 3. We don't want to B-D or Depend on any Python 2 related packages. Let's get rid of them once and for all. AFAICT, this is used as an application, not a library, so it doesn't need to be bilingual, and we definitely don't want to carry those extra dependencies. It also simplifies the code.
As for Qt4/5, what's the use case for letting that be switchable, other than the bug mentioned in my mp (which I can't reproduce here locally)? It should be hard to switch back to PyQt4, but OTOH PyQt5 works okay for me (and it passes all the tests <wink>). Does it need to be switchable, or can it be one or the other? OTOH, I don't care too much since both work in Python 3. :)
Thomi Richards (thomir-deactivatedaccount) wrote : | # |
Approving, since the Qt5 crash has been tracked down to another module. Let's land this!
129 +try:
130 + from StringIO import StringIO
131 +except ImportError:
132 + from io import StringIO
133 +
134 from mock import patch
135 -from StringIO import StringIO
We don't need to support py26 or earlier, so just import io.StringIO every time.
Otherwise, looks good