diff options
| author | Damian Johnson <atagar@torproject.org> | 2018-08-03 12:42:29 -0700 |
|---|---|---|
| committer | Damian Johnson <atagar@torproject.org> | 2018-08-03 12:42:29 -0700 |
| commit | b0c84477c5c18b0db7d60f0db6cc42cb9c0948e5 (patch) | |
| tree | deb2e4187f25ee1f4619052854a17fb32b346968 | |
| parent | ac2b277a9b09451c0270d4397ab96087ce2cbaad (diff) | |
Python3 compatability for tests
Couple regressions that mostly slipped in with the recent hashing changes.
https://trac.torproject.org/projects/tor/ticket/27030
| -rw-r--r-- | stem/client/datatype.py | 7 | ||||
| -rw-r--r-- | test/unit/client/link_protocol.py | 2 |
2 files changed, 8 insertions, 1 deletions
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 |
