def test_request_finished_when_garbage_collected(self):
        web_site = web_provider.WebSite('site_name', dict(routing=dict(__config__=dict(processor='pipeline.test_pipeline'))))
        web_site.configure(self.runtime_environment)

        batons = list()

        web_resource = self.getResourceForFakeRequest(web_site, [])
        web_resource.processor_dependency = dependencies.InstanceDependency(batons.append)
        web_resource.processor_dependency.is_ready = True

        request = DummyRequest([])
        web_resource.render(request)

        # the processor should have been asked to process a baton
        self.assertEquals(len(batons), 1)
        self.assertEquals(batons[0]['request'], request)

        # the processor didn't finish the request:
        self.assertEquals(request.finished, False)

        # .. however, when the processor loses the reference to the request, it should be
        # automatically finished:
        batons.pop()
        self.assertEquals(request.finished, True)