def test_notifyOnExpire(self):
        """
        A function registered with L{server.Session.notifyOnExpire} is called
        when the session expires.
        """
        callbackRan = [False]
        def expired():
            callbackRan[0] = True
        self.session.notifyOnExpire(expired)
        self.session.expire()
        self.assertTrue(callbackRan[0])

        A function registered with L{server.Session.notifyOnExpire} is called
        when the session expires.
        
stackoverflow/venv/lib/python3.6/site-packages/twisted/web/test/test_web.py