select_single is inconsistent with select_many
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Autopilot |
Fix Released
|
High
|
Unassigned | ||
autopilot (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
The select_many method returns an empty list when it cannot find any objects that match the specified criteria. This means we get an IndexError exception when test authors write code like this:
thing1, thing2 = app.select_
When select_many returns an unexpected number of items, this causes the test to fail (although we should probably be more explicit in the case where nothing was returned.)
select_single, however, returns None. This leads to ugly test code like this:
foo = self.app.
self.assertThat
bar = foo.select_
self.assertThat
If we made select_single raise the StateNotFoundError exception, these assertion lines wouldn't be needed any more.
Related branches
- Martin Pitt (community): Approve
- PS Jenkins bot: Approve (continuous-integration)
-
Diff: 95 lines (+17/-10)3 files modifiedautopilot/introspection/dbus.py (+5/-2)
autopilot/tests/functional/test_dbus_query.py (+10/-6)
autopilot/tests/unit/test_exceptions.py (+2/-2)
description: | updated |
Changed in autopilot: | |
status: | Fix Committed → Fix Released |
Fix committed into lp:autopilot/1.3 at revision 328, scheduled for release in autopilot, milestone Unknown