Eventually matcher can't handle the Raises matcher

Bug #1244490 reported by Leo Arias on 2013-10-25
This bug affects 2 people
Affects Status Importance Assigned to Milestone
autopilot (Ubuntu)

Bug Description

When we use Eventually in combination with the Raises matcher, the exception thrown is not caught.

>>> from autopilot.matchers import Eventually
>>> from testtools.matchers import raises
>>> matcher = Eventually(raises(RuntimeError("Hello")))
>>> def bad_fn():
... raise RuntimeError("Hello")
>>> bad_fn()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in bad_fn
RuntimeError: Hello
>>> matcher.match(bad_fn)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/autopilot/matchers/__init__.py", line 109, in match
    wait_fun(self.matcher, self.timeout)
  File "/usr/lib/python2.7/dist-packages/autopilot/matchers/__init__.py", line 125, in _callable_wait_for
    new_value = refresh_fn()
  File "<stdin>", line 2, in bad_fn
RuntimeError: Hello

Related branches

This is a bug in autopilot. The root problem is that we allow people to pass in a callable method to assertThat, like so:

self.assertThat(lambda: self.get_thing(1, 2, 3), Eventually(Equals('something')))

The Eventually matcher breaks the behavior defined in testtools - it calls the matchee when it should instead pass it to the underlying matcher.

I think we need to figure out how to fix this. Off the top of my head, there's no easy solution. Need to think about this some more. Suggestions welcome;

Leo Arias (elopio) wrote :

I'm out of ideas. For now, I won't feel bad if we just document that Eventually is not compatible with raises.

Changed in autopilot:
assignee: Leo Arias (elopio) → nobody
status: In Progress → Triaged
Changed in autopilot:
assignee: nobody → Thomi Richards (thomir)
status: Triaged → In Progress
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package autopilot - 1.4+14.04.20140212-0ubuntu1

autopilot (1.4+14.04.20140212-0ubuntu1) trusty; urgency=low

  [ CI bot ]
  * Resync trunk

  [ Christopher Lee ]
  * Deprecating the use of AutopilotTestCase.pick_app_launcher
  * Fix a regression in the "autopilot launch" command which meant that
    application arguments were taken as the application to launch. (LP:

  [ Thomi Richards ]
  * Remove ibus.py from autopilot, as it should live in lp:unity. (LP:
  * Add unit tests to the autopilot.run module.
  * Refactor parts of the 'autopilot.run' module, adding unit tests and
    simplifying the code along the way.
  * Fix docs WRT Eventually matcher's interaction with Raises() matcher.
    (LP: #1244490)
  * Get display resolution using fbset, falling back to hard coded
    values based on image codename on phablet devices.
  * Fix functional tests that started failing when window-mocker
    changed. (LP: #1278187)
  * Add unit tests for missing coverage on code that picks device
    backends at runtime.
  * Fix a bug where autopilot didn't do the right thing with non-unicode
    valid bytestrings. (LP: #1278272)
 -- Ubuntu daily release <email address hidden> Wed, 12 Feb 2014 01:14:02 +0000

Changed in autopilot (Ubuntu):
status: New → Fix Released
Changed in autopilot:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers