[Piglit] [PATCH 2/5] framework/status.py: Add a __hash__ method to Status class

Dylan Baker baker.dylan.c at gmail.com
Thu Jul 2 16:46:45 PDT 2015


This is necessary in Python 3 to put a Status in a dictionary or set,
but is optional in python 2. It doesn't do any harm implementing it now,
and will easy the python 3 transition

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/status.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/framework/status.py b/framework/status.py
index ec873d8..98a9e3d 100644
--- a/framework/status.py
+++ b/framework/status.py
@@ -196,6 +196,9 @@ class Status(object):
     def __int__(self):
         return self.value
 
+    def __hash__(self):
+        return hash(self.name)
+
 
 class NoChangeStatus(Status):
     """ Special sublcass of status that overides rich comparison methods
-- 
2.4.5



More information about the Piglit mailing list