def test_Iter2FileLikeObject(self): flo = sync._Iter2FileLikeObject(iter(['123', '4567', '89', '0'])) expect = '1234567890' got = flo.read(2) self.assertTrue(len(got) <= 2) self.assertEquals(got, expect[:len(got)]) expect = expect[len(got):] got = flo.read(5) self.assertTrue(len(got) <= 5) self.assertEquals(got, expect[:len(got)]) expect = expect[len(got):] self.assertEquals(flo.read(), expect) self.assertEquals(flo.read(), '') self.assertEquals(flo.read(2), '') flo = sync._Iter2FileLikeObject(iter(['123', '4567', '89', '0'])) self.assertEquals(flo.read(), '1234567890') self.assertEquals(flo.read(), '') self.assertEquals(flo.read(2), '')