'The C{\'SCRIPT_NAME\'} key of the C{environ} C{dict} passed to the
application contains the I{abs_path} (RFC 2396, section 3) to this
resource (RFC 3875, section 4.1.13).'

def test_scriptName(self):

    root = self.render('GET', '1.1', [], [''])
    root.addCallback(self.environKeyEqual('SCRIPT_NAME', ''))
    emptyChild = self.render('GET', '1.1', [''], [''])
    emptyChild.addCallback(self.environKeyEqual('SCRIPT_NAME', '/'))
    leaf = self.render('GET', '1.1', ['foo'], ['foo'])
    leaf.addCallback(self.environKeyEqual('SCRIPT_NAME', '/foo'))
    container = self.render('GET', '1.1', ['foo', ''], ['foo', ''])
    container.addCallback(self.environKeyEqual('SCRIPT_NAME', '/foo/'))
    internal = self.render('GET', '1.1', ['foo'], ['foo', 'bar'])
    internal.addCallback(self.environKeyEqual('SCRIPT_NAME', '/foo'))
    unencoded = self.render('GET', '1.1', ['foo', '/', 'bar\xff'], ['foo', '/', 'bar\xff'])
    unencoded.addCallback(self.environKeyEqual('SCRIPT_NAME', '/foo///bar\xff'))
    return gatherResults([root, emptyChild, leaf, container, internal, unencoded])
