Activity log for bug #1225692

Date Who What changed Old value New value Message
2013-09-15 14:41:02 Thomi Richards bug added bug
2013-09-15 16:33:43 Thomi Richards description The select_many method raises an exception when it cannot find any objects that match the specified criteria. select_single, however, returns None. This leads to ugly test code like this: foo = self.app.select_single('SomeWidget') self.assertThat(foo, NotEquals(None)) bar = foo.select_single('SomeOtherWidget') self.assertThat(bar, NotEquals(None)) If we made select_single raise the same exception as select_many, these assertion lines wouldn't be needed any more. 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_many('Things') 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.select_single('SomeWidget') self.assertThat(foo, NotEquals(None)) bar = foo.select_single('SomeOtherWidget') self.assertThat(bar, NotEquals(None)) If we made select_single raise the StateNotFoundError exception, these assertion lines wouldn't be needed any more.
2013-09-15 17:47:00 Launchpad Janitor branch linked lp:~thomir/autopilot/fix-select-single
2013-09-16 14:48:08 PS Jenkins bot autopilot: status In Progress Fix Committed
2013-09-18 14:14:01 Launchpad Janitor autopilot (Ubuntu): status New Fix Released
2013-09-25 02:52:56 Thomi Richards autopilot: status Fix Committed Fix Released
2013-10-30 02:49:07 Launchpad Janitor branch linked lp:ubuntu/autopilot