def test_readline(self): it = ['hello ', 'world!', '\ngoodbye world!', ''] iterfile = IterFile(it) assert iterfile.readline() == 'hello world!\n' assert iterfile.readline() == 'goodbye world!' assert iterfile.readline() == '' assert iterfile.read() == ''
def test_close(self): it = ['hello ', 'world!', '\ngoodbye world!', ''] iterfile = IterFile(it) assert iterfile.readline() == 'hello world!\n' iterfile.close() self.assertRaises(IOError, iterfile.read) self.assertRaises(IOError, iterfile.readline) self.assertRaises(IOError, iterfile.readlines) self.assertRaises(IOError, iter(iterfile).next) iterfile.close()