def test_sourceFragmentElement(self):
        """
        L{_SourceFragmentElement} renders source lines at and around the line
        number indicated by a frame object.
        """
        element = _SourceFragmentElement(
            TagLoader(tags.div(
                    tags.span(render="lineNumber"),
                    tags.span(render="sourceLine"),
                    render="sourceLines")),
            self.frame)

        source = [
            u' \N{NO-BREAK SPACE} \N{NO-BREAK SPACE}message = '
            u'"This is a problem"',

            u' \N{NO-BREAK SPACE} \N{NO-BREAK SPACE}raise Exception(message)',
            u'# Figure out the line number from which the exception will be '
            u'raised.',
        ]
        d = flattenString(None, element)
        if _PY3:
            stringToCheckFor = ''.join([
                '<div class="snippet%sLine"><span>%d</span><span>%s</span>'
                '</div>' % (
                    ["", "Highlight"][lineNumber == 1],
                    self.base + lineNumber,
                    (u" \N{NO-BREAK SPACE}" * 4 + sourceLine))
                for (lineNumber, sourceLine)
                in enumerate(source)]).encode("utf8")

        else:
            stringToCheckFor = ''.join([
                '<div class="snippet%sLine"><span>%d</span><span>%s</span>'
                '</div>' % (
                    ["", "Highlight"][lineNumber == 1],
                    self.base + lineNumber,
                    (u" \N{NO-BREAK SPACE}" * 4 + sourceLine).encode('utf8'))
                for (lineNumber, sourceLine)
                in enumerate(source)])

        d.addCallback(self.assertEqual, stringToCheckFor)
        return d

        L{_SourceFragmentElement} renders source lines at and around the line
        number indicated by a frame object.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_util.py