Fix NameError during tear_down

"file" is no longer a thing in Python 3; in which case use io.IOBase instead.