summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2009-08-22 15:03:42 +0200
committerGuido Günther <agx@sigxcpu.org>2009-08-23 17:28:49 +0200
commita4fd8ebf6b7a7fbc8abc5a1a3260dca759f88c3f (patch)
tree569ff82caf695728e61e0bf1b9da7494c063d73c
parent4cd72bc7efc04fddf39b208b3d0bb7293bc904d9 (diff)
add doctest for Command.call()
and fix error in exception handling revealed by the test.
-rw-r--r--gbp/command_wrappers.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index b73549b3..64874891 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -83,11 +83,18 @@ class Command(object):
raise CommandExecFailed
def call(self, args):
- """like __call__ but don't use stderr and let the caller handle the return status"""
+ """like __call__ but don't use stderr and let the caller handle the return status
+ >>> Command("/bin/true").call(["foo", "bar"])
+ 0
+ >>> Command("/foo/bar").call(["foo", "bar"]) # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ CommandExecFailed: Execution failed: ...
+ """
try:
ret = self.__call(args)
except OSError, e:
- raise CommandExecFailed, "Execution failed:", e
+ raise CommandExecFailed, "Execution failed: %s" % e
return ret