class QDataStreamWrite(unittest.TestCase): '''Test case for QDatastream write* functions''' def setUp(self): self.ba = QByteArray() self.read = QDataStream(self.ba, QIODevice.ReadOnly) self.write = QDataStream(self.ba, QIODevice.WriteOnly) def testWriteUInt8(self): '''QDataStream.writeUInt8 (accepting str of size 1)''' x = 0xFF self.write.writeUInt8(x) y = self.read.readUInt8() self.assertEqual(x, y) self.assertRaises(TypeError, self.write.writeUInt8, 'aaaaa') def testWriteInt8(self): '''QDataStream.writeInt8 (accepting str of size 1)''' x = 65 self.write.writeInt8(chr(x)) y = self.read.readInt8() self.assertEqual(x, y) self.assertRaises(TypeError, self.write.writeInt8, 'aaaaa') def testWriteUInt8Int(self): '''QDataStream.writeUInt8 (accepting integer)''' x = 0xFF self.write.writeUInt8(x) y = self.read.readUInt8() self.assertEqual(x, y) def testWriteInt8Int(self): '''QDataStream.writeInt8 (accepting integer)''' x = 65 self.write.writeInt8(x) y = self.read.readInt8() self.assertEqual(x, y) def testWriteUInt16(self): '''QDataStream.writeUInt16''' x = 0x4423 self.write.writeUInt16(x) y = int(self.read.readUInt16()) self.assertEqual(x, y) def testWriteUInt32(self): '''QDataStream.writeUInt32''' x = 0xdeadbeef self.write.writeUInt32(x) y = int(self.read.readUInt32()) self.assertEqual(x, y)
def __lshift__(self, Sender: QDataStream): self.Connect = Sender.readInt8() print("CONNECT CHECK REQUEST LOAD FROM DATA STREAM")