def test_forbiddenResource_customize(self):
    '\n        The resource rendered for forbidden requests is stored as a class\n        member so that users can customize it.\n        '
    base = FilePath(self.mktemp())
    base.setContent(b'')
    markerResponse = b'custom-forbidden-response'

    def failingOpenForReading():
        raise IOError(errno.EACCES, '')

    class CustomForbiddenResource(resource.Resource):

        def render(self, request):
            return markerResponse

    class CustomStaticFile(static.File):
        forbidden = CustomForbiddenResource()
    fileResource = CustomStaticFile(base.path)
    fileResource.openForReading = failingOpenForReading
    request = DummyRequest([b''])
    result = fileResource.render(request)
    self.assertEqual(markerResponse, result)
The resource rendered for forbidden requests is stored as a class
member so that users can customize it.
def test_forbiddenResource_customize(self):
    '\n        The resource rendered for forbidden requests is stored as a class\n        member so that users can customize it.\n        '
    base = FilePath(self.mktemp())
    base.setContent(b)
    markerResponse = b'custom-forbidden-response'

    def failingOpenForReading():
        raise IOError(errno.EACCES, )

    class CustomForbiddenResource(resource.Resource):

        def render(self, request):
            return markerResponse

    class CustomStaticFile(static.File):
        forbidden = CustomForbiddenResource()
    fileResource = CustomStaticFile(base.path)
    fileResource.openForReading = failingOpenForReading
    request = DummyRequest([b])
    result = fileResource.render(request)
    self.assertEqual(markerResponse, result)