def fdopen(self, fd, mode=None):
        """
        Fake C{os.fdopen} implementation which returns C{self.readStream} for
        the stdin fd and C{self.writeStream} for the stdout fd.
        """
        if fd == _WORKER_AMP_STDIN:
            self.assertIdentical('rb', mode)
            return self.readStream
        elif fd == _WORKER_AMP_STDOUT:
            self.assertEqual('wb', mode)
            return self.writeStream
        else:
            raise AssertionError("Unexpected fd %r" % (fd,))

        Fake C{os.fdopen} implementation which returns C{self.readStream} for
        the stdin fd and C{self.writeStream} for the stdout fd.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/_dist/test/test_workertrial.py