def setUp(self): self.f = StringIO("0123456789") self.tfw = TricklingReadFileWrapper(self.f, 4) self.pf = PaddedFile(self.tfw, 10, 16)
class PaddedFileTest(unittest.TestCase): """ Unit test for PaddedFile """ def setUp(self): self.f = StringIO("0123456789") self.tfw = TricklingReadFileWrapper(self.f, 4) self.pf = PaddedFile(self.tfw, 10, 16) def test_read_begin_short(self): s = self.pf.read(3) self.assertEquals(s, "012") def test_read_begin_long(self): s = self.pf.read(5) self.assertEquals(s, "0123") def test_read_phys_end_short(self): self.pf.seek(9) s = self.pf.read(3) self.assertEquals(s, "9\0\0") def test_read_phys_end_long(self): self.pf.seek(9) s = self.pf.read(5) self.assertEquals(s, "9\0\0\0\0") def test_read_virt_end_short(self): self.pf.seek(12) s = self.pf.read(4) self.assertEquals(s, "\0\0\0\0") def test_read_virt_end_long(self): self.pf.seek(12) s = self.pf.read(5) self.assertEquals(s, "\0\0\0\0") def test_seek_tell(self): self.pf.seek(13) self.assertEquals(13, self.pf.tell())