def test_writeAcceptsOnlyByteStrings(self):
        """
        The C{write} callable returned from C{start_response} only accepts
        byte strings.
        """
        def application(environ, startResponse):
            write = startResponse("200 OK", [])
            write(u"bogus")
            return iter(())

        request, result = self.prepareRequest(application)
        request.requestReceived()

        def checkMessage(error):
            if _PY3:
                self.assertEqual(
                    "Can only write bytes to a transport, not 'bogus'",
                    str(error))
            else:
                self.assertEqual(
                    "Can only write bytes to a transport, not u'bogus'",
                    str(error))

        return self.assertFailure(result, TypeError).addCallback(checkMessage)

        The C{write} callable returned from C{start_response} only accepts
        byte strings.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_wsgi.py