[tor-commits] [bridgedb/master] Fix minor type issues

phw at torproject.org phw at torproject.org
Wed Feb 19 18:26:38 UTC 2020


commit 621f35b9cb02f1106a963ddb1f0b0fd23b4826bd
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Jan 19 12:52:56 2020 -0800

    Fix minor type issues
    
    Just some instances of low hanging fruit...
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_Bridges.py", line 110, in test_dumpAssignments
          first = self.ring.bridges.values()[0].fingerprint
      builtins.TypeError: 'dict_values' object does not support indexing
    
      Traceback (most recent call last):
        File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_parse_headers.py", line 37, in test_defaultTBBHeader
          self.assertIsInstance(langs, list)
        File "/usr/local/lib/python3.5/dist-packages/twisted/trial/_synctest.py", line 649, in assertIsInstance
          instance, classOrTuple, suffix))
      twisted.trial.unittest.FailTest: <map object at 0x7f986ca07ba8> is not an instance of <class 'list'>
    
    Test results changed as follows...
    
      before: FAILED (skips=115, failures=29, errors=3, successes=837)
      after:  FAILED (skips=115, failures=27, errors=2, successes=840)
---
 bridgedb/parse/headers.py     | 3 +--
 bridgedb/test/test_Bridges.py | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/bridgedb/parse/headers.py b/bridgedb/parse/headers.py
index fa8cbf2..29dd091 100644
--- a/bridgedb/parse/headers.py
+++ b/bridgedb/parse/headers.py
@@ -75,5 +75,4 @@ def parseAcceptLanguage(header):
 
     # Gettext wants underderscores, because that is how it creates the
     # directories under i18n/, not hyphens:
-    langs = map(lambda x: x.replace('-', '_'), [x for x in langs])
-    return langs
+    return list(map(lambda x: x.replace('-', '_'), [x for x in langs]))
diff --git a/bridgedb/test/test_Bridges.py b/bridgedb/test/test_Bridges.py
index 1f4720f..8f629f5 100644
--- a/bridgedb/test/test_Bridges.py
+++ b/bridgedb/test/test_Bridges.py
@@ -107,7 +107,7 @@ class BridgeRingTests(unittest.TestCase):
         f.seek(0)
 
         data = f.read()
-        first = self.ring.bridges.values()[0].fingerprint
+        first = list(self.ring.bridges.values())[0].fingerprint
 
         # The first bridge's fingerprint should be within the data somewhere
         self.assertIn(first, data)





More information about the tor-commits mailing list