Pytest asserting from another function's callback
I am using pytest to test an airplane state transition. I am testing the
landing() function that is predefined and calling it from another function. It looks something like this:
def landing(): airplane_actions.decrease_altitude(ft=10000) time.sleep(30) airplane_actions.decrease_altitude(ft=5000) time.sleep(30) airplane_actions.decrease_altitude(ft=0)
In my testing module,
test_plane_actions.py, I am calling this
landing() function, however, I want to be able to assert the altitude values before each sleep.
def test_plane_actions(): # Do some setups # assert plane_actions.landing() # I want to assert the altitudes in here from this function.
Is there a way to have the landing() function callback the
test_plane_actions.py module during each sleep period and make an assert during each sleep period? Or perhaps a delayed assert? Let's assume we cannot decompose the
landing() function and I want to be able to just call it in the