Merge lp:~coreygoldberg/window-mocker/wm-fix1278917 into lp:window-mocker

Proposed by Corey Goldberg
Status: Merged
Merged at revision: 26
Proposed branch: lp:~coreygoldberg/window-mocker/wm-fix1278917
Merge into: lp:window-mocker
Diff against target: 101 lines (+30/-9)
2 files modified
tests/test_app_functional.py (+26/-7)
windowmocker/plugins/qt4.py (+4/-2)
To merge this branch: bzr merge lp:~coreygoldberg/window-mocker/wm-fix1278917
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Autopilot Hackers Pending
Review via email: mp+206036@code.launchpad.net

Commit message

fixed qt4 plugin, previous regression

Description of the change

this branch fixes the window-mocker regression currently in trunk.

in qt4.py, changed use of..

isinstance(item, str)

to:

isinstance(item, six.string_types)

using six, so unicode types are accepted under Python2.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
27. By Corey Goldberg

fixed qt4 plugin

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
28. By Corey Goldberg

test with menus

29. By Corey Goldberg

fix unit test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
30. By Corey Goldberg

fixed json error message

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/test_app_functional.py'
2--- tests/test_app_functional.py 2014-02-05 16:21:50 +0000
3+++ tests/test_app_functional.py 2014-02-20 22:11:58 +0000
4@@ -8,6 +8,7 @@
5
6 """Functional tests for the window-mocker application."""
7
8+import json
9 import os
10 import subprocess
11 import tempfile
12@@ -15,7 +16,7 @@
13 from time import sleep
14
15 from testtools import TestCase
16-from testtools.matchers import Contains, Equals
17+from testtools.matchers import Contains, Equals, MatchesAny
18
19
20 def get_app_path():
21@@ -57,16 +58,16 @@
22 )
23
24 stdout = stderr = ""
25- for i in range(10):
26+ for i in range(3):
27 retcode = process.poll()
28 if retcode is not None:
29 break
30- if i == 5:
31+ if i == 1:
32+ print("Terminating process.")
33+ process.terminate()
34+ if i == 2:
35 print("Killing process.")
36 process.kill()
37- if i == 8:
38- print("Terminating process.")
39- process.terminate()
40 sleep(1)
41 stdout, stderr = process.communicate()
42 return (retcode, stdout, stderr)
43@@ -84,6 +85,18 @@
44 f.write(content_string)
45 return run_app_with_args(temp_filename)
46
47+ def test_spec_with_menus(self):
48+ window_spec = {
49+ "Title": "Test menu application",
50+ "Menu": ["Search entry", "Quit"],
51+ }
52+ fd, temp_filename = tempfile.mkstemp()
53+ self.addCleanup(os.remove, temp_filename)
54+ os.close(fd)
55+ with open(temp_filename, 'w') as f:
56+ f.write(json.dumps(window_spec))
57+ return run_app_with_args(temp_filename)
58+
59 def test_errors_with_missing_file(self):
60 retcode, stdout, stderr = run_app_with_args("bad_file_name")
61 self.assertThat(stdout, Equals(''))
62@@ -108,7 +121,13 @@
63
64 self.assertThat(stdout, Equals(''))
65 self.assertThat(retcode, Equals(3))
66- self.assertThat(stderr, Equals('Error: Unable to process request: No JSON object could be decoded\n'))
67+ self.assertThat(
68+ stderr,
69+ MatchesAny(
70+ Equals('Error: Unable to process request: No JSON object could be decoded\n'),
71+ Equals('Error: Unable to process request: Expecting value: line 1 column 1 (char 0)\n'),
72+ )
73+ )
74
75 def test_accepts_testability_command_line_argument(self):
76 retcode, stdout, stderr = run_app_with_args("--help")
77
78=== modified file 'windowmocker/plugins/qt4.py'
79--- windowmocker/plugins/qt4.py 2014-02-05 16:21:50 +0000
80+++ windowmocker/plugins/qt4.py 2014-02-20 22:11:58 +0000
81@@ -7,8 +7,10 @@
82 # by the Free Software Foundation.
83
84 import logging
85+import sys
86+
87+import six
88 from PyQt4 import QtCore, QtGui
89-import sys
90
91 from windowmocker.plugins.base import ApplicationTypePluginBase
92
93@@ -62,7 +64,7 @@
94 menu = parent.addMenu(title)
95 if 'Menu' in item:
96 self._create_menus(menu, item['Menu'])
97- elif isinstance(item, str):
98+ elif isinstance(item, six.string_types):
99 parent.addAction(item)
100 else:
101 logger.error("Invalid menu item - is not a dict or string: %r", item)

Subscribers

People subscribed via source and target branches