[tor-commits] [stem/master] Fixing a couple python 3 network status document TypeErrors

atagar at torproject.org atagar at torproject.org
Mon Oct 14 00:42:16 UTC 2013


commit e1bf7cbacb8797845c1bc2a778baa93d9748f4c9
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Oct 13 12:10:38 2013 -0700

    Fixing a couple python 3 network status document TypeErrors
    
    ======================================================================
    ERROR: test_duplicate_fields
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/atagar/Desktop/stem/test/data/python3/test/unit/descriptor/networkstatus/document_v3.py", line 247, in test_duplicate_fields
        if not is_consensus and lines[index].startswith('dir-source'):
    TypeError: startswith first arg must be bytes or a tuple of bytes, not str
    
    ======================================================================
    ERROR: test_misordered_fields
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/atagar/Desktop/stem/test/data/python3/test/unit/descriptor/networkstatus/document_v3.py", line 225, in test_misordered_fields
        elif not is_consensus and lines[index].startswith('dir-source'):
    TypeError: startswith first arg must be bytes or a tuple of bytes, not str
    
    ----------------------------------------------------------------------
    Ran 35 tests in 0.234s
---
 test/unit/descriptor/networkstatus/document_v3.py |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/unit/descriptor/networkstatus/document_v3.py b/test/unit/descriptor/networkstatus/document_v3.py
index 71ef8b6..4c82617 100644
--- a/test/unit/descriptor/networkstatus/document_v3.py
+++ b/test/unit/descriptor/networkstatus/document_v3.py
@@ -222,7 +222,7 @@ class TestNetworkStatusDocument(unittest.TestCase):
 
         if is_consensus and lines[index].startswith(stem.util.str_tools._to_bytes(CRYPTO_BLOB[1:10])):
           break
-        elif not is_consensus and lines[index].startswith('dir-source'):
+        elif not is_consensus and lines[index].startswith(b'dir-source'):
           break
 
         # swaps this line with the one after it
@@ -244,7 +244,7 @@ class TestNetworkStatusDocument(unittest.TestCase):
       lines = get_network_status_document_v3(attr, content = True).split(b"\n")
 
       for index, line in enumerate(lines):
-        if not is_consensus and lines[index].startswith('dir-source'):
+        if not is_consensus and lines[index].startswith(b'dir-source'):
           break
 
         # Stop when we hit the 'directory-signature' for a couple reasons...





More information about the tor-commits mailing list