Fake_wx objects now support comparison and hashing
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sat, 20 May 2023 00:35:41 +0200
changeset 3809 45accb98d761
parent 3808 3e219f00151a
child 3810 eafb8f000584
Fake_wx objects now support comparison and hashing
fake_wx.py
--- a/fake_wx.py	Sat May 20 00:33:22 2023 +0200
+++ b/fake_wx.py	Sat May 20 00:35:41 2023 +0200
@@ -23,14 +23,25 @@
         return FakeObject(__classname__=self.__classname__+"()")
 
     def __getitem__(self, key):
-        raise IndexError(key)
+        return FakeObject(__classname__=self.__classname__+"["+repr(key)+"]")
 
     def __str__(self):
         return self.__classname__
 
     def __or__(self, other):
         return FakeObject(__classname__=self.__classname__+"|"+other.__classname__)
+    
+    def __hash__(self) -> int:
+        return id(self)
 
+    def __cmp__(self,other):
+        return True
+    __lt__=__cmp__
+    __le__=__cmp__
+    __eq__=__cmp__
+    __ne__=__cmp__
+    __gt__=__cmp__
+    __ge__=__cmp__
 
 class FakeClass:
     def __init__(self, *args, **kwargs):