This is a butterfly pupal case after the butterfly has emerged from it. It is about 25 mm long.
I was given the foodplant for this and several other species of butterflies - Coast Caper (Capparis lucida) - to plant in my garden.
I saw a Caper Gull laying eggs on it, but could not subsequently find a caterpillar so I thought breeding had failed ... until I found this.
I've yet to obtain a good photo of the adult butterfly.