def test_nonDefaultDoctype(self):
        """
        L{renderElement} will write the doctype string specified by the
        doctype keyword argument.
        """
        element = TestElement()

        d = self.request.notifyFinish()

        def check(_):
            self.assertEqual(
                b"".join(self.request.written),
                (b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
                 b' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n'
                 b'<p>Hello, world.</p>'))

        d.addCallback(check)

        renderElement(
            self.request,
            element,
            doctype=(
                b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"'
                b' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'))

        return d

        L{renderElement} will write the doctype string specified by the
        doctype keyword argument.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_template.py