Merge lp:~thomir-deactivatedaccount/autopilot/remove-incompatible-changes into lp:autopilot/1.3

Proposed by Thomi Richards
Status: Merged
Approved by: Thomi Richards
Approved revision: 332
Merged at revision: 332
Proposed branch: lp:~thomir-deactivatedaccount/autopilot/remove-incompatible-changes
Merge into: lp:autopilot/1.3
Diff against target: 147 lines (+9/-68)
2 files modified
autopilot/introspection/dbus.py (+2/-39)
autopilot/tests/functional/test_dbus_query.py (+7/-29)
To merge this branch: bzr merge lp:~thomir-deactivatedaccount/autopilot/remove-incompatible-changes
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Leo Arias (community) code review. Approve
Autopilot Hackers Pending
Review via email: mp+186086@code.launchpad.net

Commit message

Back out changes that would break test case compatibility.

Description of the change

This branch removes the changes that makes autopilot incompatible with test cases. Namely, it removes the following:

 * Addition of the wait_select_single method.
 * Change to make select-single raise a StateNotFound error instead of returning None.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

Sad, but sane. Thanks.

review: Approve (code review.)
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 'autopilot/introspection/dbus.py'
2--- autopilot/introspection/dbus.py 2013-09-16 15:22:01 +0000
3+++ autopilot/introspection/dbus.py 2013-09-17 15:59:21 +0000
4@@ -168,7 +168,6 @@
5 self.__refresh_on_attribute = True
6 self._set_properties(state_dict)
7 self._path = path
8- self._poll_time = 10
9
10 def _set_properties(self, state_dict):
11 """Creates and set attributes of *self* based on contents of
12@@ -360,8 +359,7 @@
13 app.select_single('QPushButton', objectName='clickme')
14 # returns a QPushButton whose 'objectName' property is 'clickme'.
15
16- If nothing is returned from the query, this method raises
17- StateNotFoundError.
18+ If nothing is returned from the query, this method returns None.
19
20 :param type_name: Either a string naming the type you want, or a class
21 of the appropriate type (the latter case is for overridden emulator
22@@ -373,8 +371,6 @@
23 :raises TypeError: if neither *type_name* or keyword filters are
24 provided.
25
26- :raises StateNotFoundError: if the requested object was not found.
27-
28 .. seealso::
29 Tutorial Section :ref:`custom_emulators`
30
31@@ -383,42 +379,9 @@
32 if len(instances) > 1:
33 raise ValueError("More than one item was returned for query")
34 if not instances:
35- raise StateNotFoundError(type_name, **kwargs)
36+ return None
37 return instances[0]
38
39- def wait_select_single(self, type_name='*', **kwargs):
40- """Does the same thing as :meth:`select_single`, but will poll the
41- application continually until a valid object is found. This is useful
42- in situations where the object you are trying to select may not exist
43- yet.
44-
45- After 10 seconds, a StateNotFoundError will be raised, as if the
46- :meth:`select_single` method had been called instead.
47-
48- :param type_name: Either a string naming the type you want, or a class
49- of the appropriate type (the latter case is for overridden emulator
50- classes).
51-
52- :raises ValueError: if the query returns more than one item. *If
53- you want more than one item, use select_many instead*.
54-
55- :raises TypeError: if neither *type_name* or keyword filters are
56- provided.
57-
58- :raises StateNotFoundError: if the requested object was not found.
59-
60- .. seealso::
61- Tutorial Section :ref:`custom_emulators`
62-
63- """
64- for i in range(self._poll_time):
65- try:
66- return self.select_single(type_name, **kwargs)
67- except StateNotFoundError:
68- if i == self._poll_time - 1:
69- raise
70- sleep(1)
71-
72 def select_many(self, type_name='*', **kwargs):
73 """Get a list of nodes from the introspection tree, with type equal to
74 *type_name* and (optionally) matching the keyword filters present in
75
76=== modified file 'autopilot/tests/functional/test_dbus_query.py'
77--- autopilot/tests/functional/test_dbus_query.py 2013-09-16 13:02:23 +0000
78+++ autopilot/tests/functional/test_dbus_query.py 2013-09-17 15:59:21 +0000
79@@ -22,12 +22,10 @@
80 import os
81 import subprocess
82 import signal
83-from time import time
84 from tempfile import mktemp
85
86 from autopilot.testcase import AutopilotTestCase
87-from testtools.matchers import Equals, NotEquals, raises, LessThan, GreaterThan
88-from autopilot.introspection.dbus import StateNotFoundError
89+from testtools.matchers import Equals, NotEquals, raises
90
91
92 class DbusQueryTests(AutopilotTestCase):
93@@ -128,10 +126,10 @@
94 fn = lambda: app.select_single()
95 self.assertThat(fn, raises(TypeError))
96
97- def test_select_single_no_match_raises_exception(self):
98+ def test_select_single_no_match_returns_none(self):
99 app = self.start_fully_featured_app()
100- match_fn = lambda: app.select_single("QMadeupType")
101- self.assertThat(match_fn, raises(StateNotFoundError('QMadeupType')))
102+ failed_match = app.select_single("QMadeupType")
103+ self.assertThat(failed_match, Equals(None))
104
105 def test_select_single_parameters_only(self):
106 app = self.start_fully_featured_app()
107@@ -140,13 +138,10 @@
108 self.assertThat(titled_help, NotEquals(None))
109 self.assertThat(titled_help.title, Equals('Help'))
110
111- def test_select_single_parameters_no_match_raises_exception(self):
112+ def test_select_single_parameters_no_match_returns_none(self):
113 app = self.start_fully_featured_app()
114- match_fn = lambda: app.select_single(title="Non-existant object")
115- self.assertThat(
116- match_fn,
117- raises(StateNotFoundError(title="Non-existant object"))
118- )
119+ failed_match = app.select_single(title="Non-existant object")
120+ self.assertThat(failed_match, Equals(None))
121
122 def test_select_single_returning_multiple_raises(self):
123 app = self.start_fully_featured_app()
124@@ -168,23 +163,6 @@
125 failed_match = app.select_many('QMenu', title='qwerty')
126 self.assertThat(failed_match, Equals([]))
127
128- def test_wait_select_single_succeeds_quickly(self):
129- app = self.start_fully_featured_app()
130- start_time = time()
131- main_window = app.wait_select_single('QMainWindow')
132- end_time = time()
133- self.assertThat(main_window, NotEquals(None))
134- self.assertThat(abs(end_time - start_time), LessThan(1))
135-
136- def test_wait_select_single_fails_slowly(self):
137- app = self.start_fully_featured_app()
138- start_time = time()
139- fn = lambda: app.wait_select_single('QMadeupType')
140- self.assertThat(fn, raises(StateNotFoundError('QMadeupType')))
141- end_time = time()
142- self.assertThat(abs(end_time - start_time), GreaterThan(9))
143- self.assertThat(abs(end_time - start_time), LessThan(11))
144-
145
146 class DbusCustomBusTests(AutopilotTestCase):
147 """Test the ability to use custom dbus buses during a test."""

Subscribers

People subscribed via source and target branches

to all changes: