[tor-commits] [stem/master] Unit test python3 regression

atagar at torproject.org atagar at torproject.org
Tue Jan 22 19:04:59 UTC 2019


commit 155770c57dca0b7f6d93ce35237412346a12f707
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Jan 21 19:03:20 2019 -0800

    Unit test python3 regression
    
    Huh. Guess I don't test via python3 much. Commit 5488849 changed our annotation
    values to unicode. Unsure that was intentional in that commit but I think
    that's preferable so adjusting our tests.
    
      ======================================================================
      FAIL: test_annotations
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/usr/lib/python3.5/unittest/mock.py", line 1157, in patched
          return func(*args, **keywargs)
        File "/home/atagar/Desktop/stem/test/unit/descriptor/server_descriptor.py", line 739, in test_annotations
          self.assertEqual(b'@pepperjack very tasty', desc.get_annotation_lines()[0])
      AssertionError: b'@pepperjack very tasty' != '@pepperjack very tasty'
    
      ----------------------------------------------------------------------
---
 stem/descriptor/server_descriptor.py      | 4 ++--
 test/unit/descriptor/server_descriptor.py | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/stem/descriptor/server_descriptor.py b/stem/descriptor/server_descriptor.py
index 70f31867..6cc0e775 100644
--- a/stem/descriptor/server_descriptor.py
+++ b/stem/descriptor/server_descriptor.py
@@ -698,8 +698,8 @@ class ServerDescriptor(Descriptor):
     annotation_dict = {}
 
     for line in self._annotation_lines:
-      if b' ' in line:
-        key, value = line.split(b' ', 1)
+      if ' ' in line:
+        key, value = line.split(' ', 1)
         annotation_dict[key] = value
       else:
         annotation_dict[line] = None
diff --git a/test/unit/descriptor/server_descriptor.py b/test/unit/descriptor/server_descriptor.py
index 7c0ebe97..49cf327e 100644
--- a/test/unit/descriptor/server_descriptor.py
+++ b/test/unit/descriptor/server_descriptor.py
@@ -736,9 +736,9 @@ Qlx9HNCqCY877ztFRC624ja2ql6A2hBcuoYMbkHjcQ4=
     desc = desc_entries[0]
 
     self.assertEqual('caerSidi', desc.nickname)
-    self.assertEqual(b'@pepperjack very tasty', desc.get_annotation_lines()[0])
-    self.assertEqual(b'@mushrooms not so much', desc.get_annotation_lines()[1])
-    self.assertEqual({b'@pepperjack': b'very tasty', b'@mushrooms': b'not so much'}, desc.get_annotations())
+    self.assertEqual('@pepperjack very tasty', desc.get_annotation_lines()[0])
+    self.assertEqual('@mushrooms not so much', desc.get_annotation_lines()[1])
+    self.assertEqual({'@pepperjack': 'very tasty', '@mushrooms': 'not so much'}, desc.get_annotations())
     self.assertEqual([], desc.get_unrecognized_lines())
 
   def test_duplicate_field(self):





More information about the tor-commits mailing list