Commits

Rune Halvorsen  committed 202dff7

Made the ref tests parse as well as serialize

  • Participants
  • Parent commits 167d88e

Comments (0)

Files changed (1)

File tests/test_reference.py

     Pbl = unitmsg.TestAllTypes
 
     def testprop(**kwargs):
-        p = Pbl()
-        r = Ref()
+        p1 = Pbl()
+        r1 = Ref()
 
         for key, val in kwargs.items():
-            setattr(p, key, val)
-            setattr(r, key, val)
+            setattr(p1, key, val)
+            setattr(r1, key, val)
 
-        if r.SerializeToString() != p.serialize():
-            print "ref", [hex(ord(e)) for e in r.SerializeToString()]
-            print "pbl", [hex(ord(e)) for e in p.serialize()]
+        assert r1.SerializeToString() == p1.serialize()
 
+        p2 = Pbl.parse(r1.SerializeToString())
+        r2 = Ref()
+        r2.ParseFromString(p1.serialize())
 
-        assert r.SerializeToString() == p.serialize()
+        for key, val in kwargs.items():
+            print getattr(p2, key), getattr(r2, key), key
+            assert getattr(p2, key) == getattr(r2, key) == val
 
 
     testprop(optional_int32=1)