def test_staticFile(self):
    '\n        If a request is made which encounters a L{File} before a final segment\n        which names a file in the path the L{File} was created with, that file\n        is served as the response to the request.\n        '
    base = FilePath(self.mktemp())
    base.makedirs()
    base.child('foo.bar').setContent(b'baz')
    file = static.File(base.path)
    request = DummyRequest([b'foo.bar'])
    child = resource.getChildForRequest(file, request)
    d = self._render(child, request)

    def cbRendered(ignored):
        self.assertEqual(b''.join(request.written), b'baz')
        self.assertEqual(request.responseHeaders.getRawHeaders(b'content-length')[0], b'3')
    d.addCallback(cbRendered)
    return d
If a request is made which encounters a L{File} before a final segment
which names a file in the path the L{File} was created with, that file
is served as the response to the request.
def test_staticFile(self):
    '\n        If a request is made which encounters a L{File} before a final segment\n        which names a file in the path the L{File} was created with, that file\n        is served as the response to the request.\n        '
    base = FilePath(self.mktemp())
    base.makedirs()
    base.child('foo.bar').setContent(b'baz')
    file = static.File(base.path)
    request = DummyRequest([b'foo.bar'])
    child = resource.getChildForRequest(file, request)
    d = self._render(child, request)

    def cbRendered(ignored):
        self.assertEqual(b.join(request.written), b'baz')
        self.assertEqual(request.responseHeaders.getRawHeaders(b'content-length')[0], b'3')
    d.addCallback(cbRendered)
    return d