def test_serializeUnicode(self):
        """
        Test that unicode is encoded correctly in the appropriate places, and
        raises an error when it occurs in inappropriate place.
        """
        snowman = u'\N{SNOWMAN}'
        return gatherResults([
            self.assertFlattensTo(snowman, b'\xe2\x98\x83'),
            self.assertFlattensTo(tags.p(snowman), b'<p>\xe2\x98\x83</p>'),
            self.assertFlattensTo(Comment(snowman), b'<!--\xe2\x98\x83-->'),
            self.assertFlattensTo(CDATA(snowman), b'<![CDATA[\xe2\x98\x83]]>'),
            self.assertFlatteningRaises(
                Tag(snowman), UnicodeEncodeError),
            self.assertFlatteningRaises(
                Tag('p', attributes={snowman: ''}), UnicodeEncodeError),
        ])

        Test that unicode is encoded correctly in the appropriate places, and
        raises an error when it occurs in inappropriate place.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_flatten.py