Merge lp:~thomir/unity/wait_for-to-use-testtools-exception into lp:unity
| Status: | Superseded |
|---|---|
| Proposed branch: | lp:~thomir/unity/wait_for-to-use-testtools-exception |
| Merge into: | lp:unity |
| Prerequisite: | lp:~thomir/unity/autopilot-attribute-feature |
| Diff against target: |
36 lines (+31/-0) 1 file modified
tests/autopilot/autopilot/matchers/__init__.py (+31/-0) |
| To merge this branch: | bzr merge lp:~thomir/unity/wait_for-to-use-testtools-exception |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Tim Penhey (community) | 2012-04-16 | Needs Fixing on 2012-04-18 | |
| Alex Launi (community) | Approve on 2012-04-17 | ||
|
Review via email:
|
|||
This proposal has been superseded by a proposal from 2012-04-18.
Commit Message
Extend the autopilot wait_for feature to use testtools matcher instances as well as ordinary values. Also added an 'Eventually' matcher which makes tests more explicit.
Description of the Change
We'd like to be able to use testtools.matchers class instances with the new wait_for feature. Currently the wait_for feature allows us to do this:
emulator.
Which will wait until 'attribute' is equal to 'expected_value'. We can now extend this to use any testtools matcher object, for example:
emulator.
- or -
emulator.
This makes the wait_for feature considerably more powerful.
| Thomi Richards (thomir) wrote : | # |
Done.
| Unity Merger (unity-merger) wrote : | # |
No proposals found for merge of lp:~thomir/unity/autopilot-attribute-feature into lp:unity.
| Tim Penhey (thumper) wrote : | # |
> if not wait_fun:
You shouldn't use a bool check here. What if the object had an attribute called wait_for that returned "foo"?
Instead use:
if wait_fun is None:
raise...
- 2237. By Thomi Richards on 2012-04-18
-
Fixed code from review.
- 2238. By Thomi Richards on 2012-04-18
-
Fixed code from review.
- 2239. By Thomi Richards on 2012-04-18
-
Check match and wait_for attribute are callables.:


Given that people can write matchers that are not in the testtools class, I think a better check would be to see if it had the match method.
# Remember hasattr is dangerous. expected_ value, 'match', None) match_func) ...
match_func = getattr(
if callable(
If expected_value isn't a matcher, make it one by: expected_ value)
expected_value = Equals(
then you don't need to have two code paths inside the time loop.