def test_assertRaisesContextExpected(self):
        """
        If C{assertRaises} is used to create a context manager and an exception
        is raised from the body of the C{with} statement then the context
        manager's C{exception} attribute is set to the exception that was
        raised.
        """
        exception = ValueError('marker')

        with self.assertRaises(ValueError) as context:
            raise exception

        self.assertIs(exception, context.exception)

        If C{assertRaises} is used to create a context manager and an exception
        is raised from the body of the C{with} statement then the context
        manager's C{exception} attribute is set to the exception that was
        raised.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/trial/test/test_assertions.py