[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Python3 compatability for tests



commit b0c84477c5c18b0db7d60f0db6cc42cb9c0948e5
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Aug 3 12:42:29 2018 -0700

    Python3 compatability for tests
    
    Couple regressions that mostly slipped in with the recent hashing changes.
    
      https://trac.torproject.org/projects/tor/ticket/27030
---
 stem/client/datatype.py           | 7 +++++++
 test/unit/client/link_protocol.py | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/stem/client/datatype.py b/stem/client/datatype.py
index 4859e24a..32295317 100644
--- a/stem/client/datatype.py
+++ b/stem/client/datatype.py
@@ -349,6 +349,7 @@ class Size(Field):
     self.name = name
     self.size = size
     self.format = pack_format
+    self._hash = None
 
   @staticmethod
   def pop(packed):
@@ -376,6 +377,12 @@ class Size(Field):
 
     return self.unpack(to_unpack), remainder
 
+  def __hash__(self):
+    if self._hash is None:
+      self._hash = stem.util._hash_attr(self, 'name', 'size', 'format')
+
+    return self._hash
+
 
 class Address(Field):
   """
diff --git a/test/unit/client/link_protocol.py b/test/unit/client/link_protocol.py
index ffaa30c2..e7fbdb00 100644
--- a/test/unit/client/link_protocol.py
+++ b/test/unit/client/link_protocol.py
@@ -30,7 +30,7 @@ class TestLinkProtocol(unittest.TestCase):
     self.assertEqual(7, protocol + 2)
     self.assertEqual(3, protocol - 2)
     self.assertEqual(15, protocol * 3)
-    self.assertEqual(1, protocol / 3)
+    self.assertEqual(1, protocol // 3)
 
   def test_equality(self):
     # LinkProtocols should be comparable with both other LinkProtocols and

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits