I'd do this by making a fake backend with the pretend module. `h = hashes.SHA1(api=pretend.stub(...)); assert h.copy()._api is h._api` or similar.