diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-01-22 16:57:02 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-01-22 17:26:39 +0100 |
commit | 3a381ec683bda6b8366252967d72217befffbd61 (patch) | |
tree | 8793dae1f1d2c9d257f82573b4cfd5f569883330 /gbp | |
parent | a8267dfe2f26f28ed6505572914096f8498cfda5 (diff) |
tristate: fix __repr__
and add doctest
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/tristate.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/gbp/tristate.py b/gbp/tristate.py index 95391b90..67b1052d 100644 --- a/gbp/tristate.py +++ b/gbp/tristate.py @@ -43,12 +43,22 @@ class Tristate(object): raise TypeError def __repr__(self): - if self._state == ON: - return "on" - elif self._state == AUTO: - return "auto" + """ + >>> Tristate('on').__repr__() + 'on' + >>> Tristate(True).__repr__() + 'on' + >>> Tristate(False).__repr__() + 'off' + >>> Tristate('auto').__repr__() + 'auto' + """ + if self._state == self.ON: + return 'on' + elif self._state == self.AUTO: + return 'auto' else: - return "off" + return 'off' @classmethod def is_valid_state(self, stat): |