Code review comment for lp://staging/~tealeg/landscape-client/catch-unreachable-server

Revision history for this message
Geoff Teale (tealeg) wrote :

> [1]
>
> self._register_handlers()
> if self._bus:
> - return self._interface.register(config_path,
> - reply_handler=reply_handler,
> - error_handler=error_handler)
> + try:
> + result, message = self._interface.register(config_path)
> + except dbus.DBusException, e:
> + if e.get_dbus_name() != "org.freedesktop.DBus.Error.NoReply":
> + raise
> + else:
> + error_handler("Registration timed out.")
> + if result:
>
> The "result" variable will be undefined if error_handler() is called, and
> indeed TimeoutTest.test_register fails:
>
>
> landscape.ui.model.registration.tests.test_proxy
> TimeoutTest
> test_register ...
> [ERROR]
>
> ==============================================================================
> =
> [ERROR]
> Traceback (most recent call last):
> File "/home/free/src/client/trunk/landscape/tests/mocker.py", line 146, in
> test_method_wrapper
> result = test_method()
> File "/home/free/src/client/trunk/landscape/ui/model/registration/tests/test
> _proxy.py", line 64, in test_register
> self.proxy.register("foo", error_handler=fake_error_handler)
> File "/home/free/src/client/trunk/landscape/ui/model/registration/proxy.py",
> line 116, in register
> if result:
> exceptions.UnboundLocalError: local variable 'result' referenced before
> assignment
>
> landscape.ui.model.registration.tests.test_proxy.TimeoutTest.test_register
> ------------------------------------------------------------------------------
> -
> Ran 1 tests in 0.003s

Yup - quite right. Now fixed.

« Back to merge proposal