Force disconnect / reconnnect.
I have a somewhat strange test case scenario that I'm currently handling via pytest/fabric (as quirky as that interaction is).
For the purposes of testing a new image, I spin up ephemeral systems. We have a test case where we modify some properties of the image, disconnect, and then attempt to reconnect.
I don't seem to be able to make the disconnect / reconnect happen. I can force the disconnect by telling the backend client (paramiko) to close the session:
>>> host.backend.client.close()
but then testinfra doesn't attempt to reconnect the session afterwards:
>>> host.file('/etc/passwd').exists
*** AttributeError: 'NoneType' object has no attribute 'open_session'
>>>
Fabric will recognise the backend as having gone away and silently re-establish the connection.
In an ideal world, from my perspective, testinfra would catch that attribute error, recognise that means the connection has failed, and re-establish.