py3: use dict.items() instead of dict.iteritems() in tests
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 19 Feb 2018 21:18:52 +0530
changeset 36327 58c1368ab629
parent 36326 a2cbff474821
child 36328 8d0b0b533e09
py3: use dict.items() instead of dict.iteritems() in tests dict.iteritems() is not present in Python 3. Differential Revision: https://phab.mercurial-scm.org/D2353
tests/fakedirstatewritetime.py
tests/test-hgweb-auth.py
tests/test-log.t
tests/test-manifest.py
tests/test-mdiff.py
tests/test-pathencode.py
tests/test-template-engine.t
--- a/tests/fakedirstatewritetime.py	Mon Feb 19 15:28:54 2018 +0530
+++ b/tests/fakedirstatewritetime.py	Mon Feb 19 21:18:52 2018 +0530
@@ -29,7 +29,7 @@
     # execute what original parsers.pack_dirstate should do actually
     # for consistency
     actualnow = int(now)
-    for f, e in dmap.iteritems():
+    for f, e in dmap.items():
         if e[0] == 'n' and e[3] == actualnow:
             e = parsers.dirstatetuple(e[0], e[1], e[2], -1)
             dmap[f] = e
--- a/tests/test-hgweb-auth.py	Mon Feb 19 15:28:54 2018 +0530
+++ b/tests/test-hgweb-auth.py	Mon Feb 19 21:18:52 2018 +0530
@@ -19,7 +19,7 @@
 
 def writeauth(items):
     ui = origui.copy()
-    for name, value in items.iteritems():
+    for name, value in items.items():
         ui.setconfig('auth', name, value)
     return ui
 
@@ -36,7 +36,7 @@
         for name in ('.username', '.password'):
             if (p + name) not in auth:
                 auth[p + name] = p
-    auth = dict((k, v) for k, v in auth.iteritems() if v is not None)
+    auth = dict((k, v) for k, v in auth.items() if v is not None)
 
     ui = writeauth(auth)
 
--- a/tests/test-log.t	Mon Feb 19 15:28:54 2018 +0530
+++ b/tests/test-log.t	Mon Feb 19 21:18:52 2018 +0530
@@ -2258,7 +2258,7 @@
   >     foo = {'foo': repo[0].node()}
   >     names = lambda r: foo.keys()
   >     namemap = lambda r, name: foo.get(name)
-  >     nodemap = lambda r, node: [name for name, n in foo.iteritems()
+  >     nodemap = lambda r, node: [name for name, n in foo.items()
   >                                if n == node]
   >     ns = namespaces.namespace(
   >         "bars", templatename="bar", logname="barlog",
--- a/tests/test-manifest.py	Mon Feb 19 15:28:54 2018 +0530
+++ b/tests/test-manifest.py	Mon Feb 19 21:18:52 2018 +0530
@@ -223,7 +223,7 @@
         self.assertEqual(want, m[b'foo'])
         self.assertEqual([(b'bar/baz/qux.py', BIN_HASH_2),
                           (b'foo', BIN_HASH_1 + b'a')],
-                         list(m.iteritems()))
+                         list(m.items()))
         # Sometimes it even tries a 22-byte fake hash, but we can
         # return 21 and it'll work out
         m[b'foo'] = want + b'+'
@@ -238,7 +238,7 @@
         # suffix with iteration
         self.assertEqual([(b'bar/baz/qux.py', BIN_HASH_2),
                           (b'foo', want)],
-                         list(m.iteritems()))
+                         list(m.items()))
 
         # shows up in diff
         self.assertEqual({b'foo': ((want, f), (h, b''))}, m.diff(clean))
--- a/tests/test-mdiff.py	Mon Feb 19 15:28:54 2018 +0530
+++ b/tests/test-mdiff.py	Mon Feb 19 21:18:52 2018 +0530
@@ -16,7 +16,7 @@
                  '': [],
                  'abcabc': ['abcabc'],
                  }
-        for inp, want in cases.iteritems():
+        for inp, want in cases.items():
             self.assertEqual(mdiff.splitnewlines(inp), want)
 
 if __name__ == '__main__':
--- a/tests/test-pathencode.py	Mon Feb 19 15:28:54 2018 +0530
+++ b/tests/test-pathencode.py	Mon Feb 19 21:18:52 2018 +0530
@@ -64,7 +64,7 @@
         counts.pop(c, None)
     t = sum(counts.itervalues()) / 100.0
     fp.write('probtable = (')
-    for i, (k, v) in enumerate(sorted(counts.iteritems(), key=lambda x: x[1],
+    for i, (k, v) in enumerate(sorted(counts.items(), key=lambda x: x[1],
                                       reverse=True)):
         if (i % 5) == 0:
             fp.write('\n    ')
--- a/tests/test-template-engine.t	Mon Feb 19 15:28:54 2018 +0530
+++ b/tests/test-template-engine.t	Mon Feb 19 21:18:52 2018 +0530
@@ -13,7 +13,7 @@
   >         tmpl = self.loader(t)
   >         props = self._defaults.copy()
   >         props.update(map)
-  >         for k, v in props.iteritems():
+  >         for k, v in props.items():
   >             if k in ('templ', 'ctx', 'repo', 'revcache', 'cache', 'troubles'):
   >                 continue
   >             if hasattr(v, '__call__'):