def assertSerializes(self, brain): """ Serializes and unserializes the given brain, asserting that a round trip works properly. """ b = Brain(brain) self.assertEqual(b, Brain.from_serialized(b.serialize()))
def test_format_input2(self): self.assertEqual( Brain([Hole(), 'abc', Hole()]), Brain.from_serialized( 'gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAihjZXZlcnlibG9j\nay50ZW1wbGF0ZW1ha2VyLmhvbGUKSG9sZQpxAymBcQR9cQViVQNhYmNxBmgDKYFxB31xCGJlfXEJ\nYi4=\n' ))
def test_format_input1(self): self.assertEqual( Brain([]), Brain.from_serialized( 'gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAn1xA2Iu\n' ))
def test_format_input2(self): self.assertEqual(Brain([Hole(), 'abc', Hole()]), Brain.from_serialized('gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAihjZXZlcnlibG9j\nay50ZW1wbGF0ZW1ha2VyLmhvbGUKSG9sZQpxAymBcQR9cQViVQNhYmNxBmgDKYFxB31xCGJlfXEJ\nYi4=\n'))
def test_format_input1(self): self.assertEqual(Brain([]), Brain.from_serialized('gAJjZXZlcnlibG9jay50ZW1wbGF0ZW1ha2VyLmJyYWluCkJyYWluCnEBKYFxAn1xA2Iu\n'))
def test_format_input2(self): # If this fails due to eg. module renaming, you can recreate # correct output like: Brain([Hole(), 'abc', Hole()]).serialize() serialized = 'gAJjZWJkYXRhLnRlbXBsYXRlbWFrZXIuYnJhaW4KQnJhaW4KcQEpgXECKGNlYmRhdGEudGVtcGxh\ndGVtYWtlci5ob2xlCkhvbGUKcQMpgXEEfXEFYlUDYWJjcQZoAymBcQd9cQhiZX1xCWIu\n' self.assertEqual(Brain([Hole(), 'abc', Hole()]), Brain.from_serialized(serialized))
def test_format_input1(self): # If this fails due to eg. module renaming, you can recreate # correct output like: Brain([]).serialize() serialized = 'gAJjZWJkYXRhLnRlbXBsYXRlbWFrZXIuYnJhaW4KQnJhaW4KcQEpgXECfXEDYi4=\n' self.assertEqual(Brain([]), Brain.from_serialized(serialized))