Check for attr __name__ before trying to access it

    In order for freeze gun to play well with py.test