+            localaddr = socket.gethostbyname_ex(socket.gethostname())[2][0]
May not be a generic solution, because in another system the other ip could be first in the list.  Because the failure was in the test_file, which was basically exercising file://'localhost' in the url, I suggested that you replace with 'localhost'. I think, the solution is okay, even thought localhost has been exercised in another test.