def test_string(self): output1 = BinaryOutput() output1.dump_string('hello world') input1 = BinaryInput(output1.result()) self.assertEqual('hello world', input1.load_string()) # 7bit safe charactes will be compressed self.assertTrue(len(output1.result()) / 2 <= len('hello world')) output2 = BinaryOutput() output2.dump_string('') self.assertEqual(len('') + 1, len(output2.result()) / 2) # 7bit unsafe charactes will not be compressed output3 = BinaryOutput() output3.dump_string(u'\u1111\u1111') self.assertEqual(len(output3.result()) / 2, len(u'\u1111\u1111') + 1)