Quellcode durchsuchen

Use for loop instead of map when not iterating.

In PY3, map returns an iterator, so the funcion never gets called.
Gary van der Merwe vor 11 Jahren
Ursprung
Commit
dd8559df80
2 geänderte Dateien mit 10 neuen und 7 gelöschten Zeilen
  1. 6 3
      dulwich/tests/compat/test_client.py
  2. 4 4
      dulwich/tests/test_repository.py

+ 6 - 3
dulwich/tests/compat/test_client.py

@@ -178,7 +178,8 @@ class DulwichClientTestBase(object):
         c = self._client()
         dest = repo.Repo(os.path.join(self.gitroot, 'dest'))
         refs = c.fetch(self._build_path('/server_new.export'), dest)
-        map(lambda r: dest.refs.set_if_equals(r[0], None, r[1]), refs.items())
+        for r in refs.items():
+            dest.refs.set_if_equals(r[0], None, r[1])
         self.assertDestEqualsSrc()
 
     def test_incremental_fetch_pack(self):
@@ -188,7 +189,8 @@ class DulwichClientTestBase(object):
         c = self._client()
         dest = repo.Repo(os.path.join(self.gitroot, 'server_new.export'))
         refs = c.fetch(self._build_path('/dest'), dest)
-        map(lambda r: dest.refs.set_if_equals(r[0], None, r[1]), refs.items())
+        for r in refs.items():
+            dest.refs.set_if_equals(r[0], None, r[1])
         self.assertDestEqualsSrc()
 
     def test_fetch_pack_no_side_band_64k(self):
@@ -196,7 +198,8 @@ class DulwichClientTestBase(object):
         c._fetch_capabilities.remove('side-band-64k')
         dest = repo.Repo(os.path.join(self.gitroot, 'dest'))
         refs = c.fetch(self._build_path('/server_new.export'), dest)
-        map(lambda r: dest.refs.set_if_equals(r[0], None, r[1]), refs.items())
+        for r in refs.items():
+            dest.refs.set_if_equals(r[0], None, r[1])
         self.assertDestEqualsSrc()
 
     def test_fetch_pack_zero_sha(self):

+ 4 - 4
dulwich/tests/test_repository.py

@@ -339,13 +339,13 @@ class RepositoryTests(TestCase):
 
         try:
             r1 = Repo.init_bare(r1_dir)
-            map(lambda c: r1.object_store.add_object(r_base.get_object(c)), \
-                r1_commits)
+            for c in r1_commits:
+                r1.object_store.add_object(r_base.get_object(c))
             r1.refs['HEAD'] = r1_commits[0]
 
             r2 = Repo.init_bare(r2_dir)
-            map(lambda c: r2.object_store.add_object(r_base.get_object(c)), \
-                r2_commits)
+            for c in r2_commits:
+                r2.object_store.add_object(r_base.get_object(c))
             r2.refs['HEAD'] = r2_commits[0]
 
             # Finally, the 'real' testing!