def test_00_unicodeByteArray(self): tests = [u"asd", u"123", u"$#%", u"\u20ac", u"\u024B62"] for orig in tests: x = bincalc.unicodeToByteArray(orig) restored = bincalc.byteArrayToUnicode(x) # print repr(test), repr(x), repr(restored), restored self.assertEqual(orig, restored)
def put(self, index, value): if type(value) == int or type(value) == long: self.items[index] = bincalc.numberToBytes(value) elif type(value) == bytearray or type(value) == str: self.items[index] = bytearray(value) elif type(value) == unicode: self.items[index] = bincalc.unicodeToByteArray(value) else: raise NotImplementedError("%s not supported" % type(value))