diff options
author | Ilia Mirkin <imirkin@alum.mit.edu> | 2014-04-05 10:22:28 -0400 |
---|---|---|
committer | Ilia Mirkin <imirkin@alum.mit.edu> | 2014-04-08 16:53:50 -0400 |
commit | b22e6ffaef99d299a998568ae2062e24fdb4158f (patch) | |
tree | 6b878eee3c7c1837bd8d8851d29a5e4f68173415 /framework/status.py | |
parent | 404cc5a9c83467ce68666347163c283f0f4d0dbf (diff) |
framework: fix comparing NOTRUN/SKIP to other statuses
The current logic causes transitions involving notrun/skip to not show
up in problems. It also encodes display decisions in lt/gt/etc
operators. This change adjusts the status class to be logically simpler
by removing the special handling of lt/gt/etc so that max(status) can
work, and reorders the logic that figures out which category to select.
Tests are updated to encode the new order -- notrun/skip are now
comparable to (and less than) the other statuses, but are unordered
between one another.
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dylan Baker <baker.dylan.c@gmail.com>
Diffstat (limited to 'framework/status.py')
-rw-r--r-- | framework/status.py | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/framework/status.py b/framework/status.py index bb7c594f5..aea36509a 100644 --- a/framework/status.py +++ b/framework/status.py @@ -158,10 +158,10 @@ class Status(object): return unicode(self.name) def __lt__(self, other): - return int(self) < int(other) + return not self.__ge__(other) def __le__(self, other): - return int(self) <= int(other) + return not self.__gt__(other) def __eq__(self, other): # This must be int or status, since status comparisons are done using @@ -173,13 +173,14 @@ class Status(object): raise TypeError("Cannot compare type: {}".format(type(other))) def __ne__(self, other): - return int(self) != int(other) + return self.fraction != other.fraction or int(self) != int(other) def __ge__(self, other): - return int(self) >= int(other) + return self.fraction[1] > other.fraction[1] or ( + self.fraction[1] == other.fraction[1] and int(self) >= int(other)) def __gt__(self, other): - return int(self) > int(other) + return self.fraction[1] > other.fraction[1] or int(self) > int(other) def __int__(self): return self.value @@ -195,12 +196,6 @@ class NoChangeStatus(Status): def __init__(self, name, value=0, fraction=(0, 0)): super(NoChangeStatus, self).__init__(name, value, fraction) - def __lt__(self, other): - return False - - def __le__(self, other): - return False - def __eq__(self, other): if isinstance(other, (str, unicode, Status)): return unicode(self) == unicode(other) @@ -211,12 +206,6 @@ class NoChangeStatus(Status): return unicode(self) != unicode(other) raise TypeError("Cannot compare type: {}".format(type(other))) - def __ge__(self, other): - return False - - def __gt__(self, other): - return False - NOTRUN = NoChangeStatus('Not Run') |