I'd either do this in the test setup or use a context manager to ensure it is always undone in the event of an error or exception.