def assertFlatteningRaises(self, root, exn):
        """
        Assert flattening a root element raises a particular exception.
        """
        d = self.assertFailure(self.assertFlattensTo(root, b''), FlattenerError)
        d.addCallback(lambda exc: self.assertIsInstance(exc._exception, exn))
        return d

        Assert flattening a root element raises a particular exception.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/_util.py