Copy of upstream mock for my own purposes