def test_write(self):
        "Test to verify that the write function works as expected"
        receiver = self.Receiver()
        relay = loopback.LoopbackRelay(receiver)
        relay.write(b'abc')
        relay.write(b'def')
        self.assertEqual(receiver.data, b'')
        relay.clearBuffer()
        self.assertEqual(receiver.data, b'abcdef')
Test to verify that the write function works as expected
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_loopback.py