Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(886)

Unified Diff: mojo/python/tests/bindings_serialization_deserialization_unittest.py

Issue 643023003: mojo: Add maps to python bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_python_generator.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/python/tests/bindings_serialization_deserialization_unittest.py
diff --git a/mojo/python/tests/bindings_serialization_deserialization_unittest.py b/mojo/python/tests/bindings_serialization_deserialization_unittest.py
index c771685deb8fb1dda2c013ef287aa0594df7cafd..0d6f64315fc7dd666559812635f7051ef40e7b0c 100644
--- a/mojo/python/tests/bindings_serialization_deserialization_unittest.py
+++ b/mojo/python/tests/bindings_serialization_deserialization_unittest.py
@@ -32,6 +32,18 @@ def _TestEquality(x, y):
if isinstance(x, float) and math.isnan(x) and math.isnan(y):
return True
+ if isinstance(x, dict):
+ if len(x) != len(y):
+ print '\n%r != %r. Dictionaries are not of the same size.' % (x, y)
+ return False
+ for xk, xv in x.iteritems():
+ if xk not in y:
+ print '\n%r != %r. Key %r is not in %r.' % (x, y, xk, y)
+ return False
+ if not _TestEquality(xv, y[xk]):
+ return False
+ return True
+
if hasattr(x, '__len__'):
if len(x) != len(y):
print '\n%r != %r. Iterables are not of the same size.' % (x, y)
@@ -98,6 +110,7 @@ class SerializationDeserializationTest(unittest.TestCase):
def testTestEquality(self):
self.assertFalse(_TestEquality(1, 2))
+ self.assertTrue(_TestEquality({1: 2, 2: 1}, {2: 1, 1: 2}))
def testFooSerialization(self):
(data, _) = _NewFoo().Serialize()
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_python_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698