From 3d1607cb70bb11e83df142337e582a7f46ceabe0 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sun, 24 Oct 2010 10:15:58 -0400 Subject: [PATCH] Add pysawsim.invoke.CommandError.__repr__() method and doctest. --- pysawsim/invoke.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pysawsim/invoke.py b/pysawsim/invoke.py index 165701c..bb501e7 100644 --- a/pysawsim/invoke.py +++ b/pysawsim/invoke.py @@ -39,6 +39,9 @@ class CommandError(Exception): while executing somefunc + >>> print repr(b) # doctest: +NORMALIZE_WHITESPACE + CommandError(command='somefunc', status=1, stdout='', + stderr='could not find "somefunc"') """ def __init__(self, command=None, status=None, stdout=None, stderr=None): self.command = command @@ -59,6 +62,12 @@ class CommandError(Exception): "while executing\n %s" % self.command, ]) + def __repr__(self): + return '%s(%s)' % ( + self.__class__.__name__, + ', '.join(['%s=%s' % (attr, repr(getattr(self, attr))) + for attr in ['command', 'status', 'stdout', 'stderr']])) + def invoke(cmd_string, stdin=None, expect=(0,), cwd=None, verbose=False): """ -- 2.26.2