def test_position(self):
     lf = LogFile(self.fname)
     expected_pos = 0
     for data in lf:
         expected_pos += len(self.make_line(data))
         real_pos = lf.position()
         print expected_pos, real_pos
         assert real_pos == expected_pos
示例#2
0
 def test_position(self):
     lf = LogFile(self.fname)
     expected_pos = 0
     for data in lf:
         expected_pos += len(self.make_line(data))
         real_pos = lf.position()
         print expected_pos, real_pos
         assert real_pos == expected_pos
 def test_seek(self):
     lf = LogFile(self.fname)
     for data in lf:
         print repr(data)
     # now we are at the current end, remember position
     pos = lf.position()
     # add new data
     newdata = [u'1303333333000000', u'00000003', u'SAVE', u'foo', u'0.0.0.0', u'example.org', u'666.666.666', u'', u'comment']
     lf.add(*newdata)
     # go to position before new data
     lf.seek(pos)
     assert lf.position() == pos
     for data in lf:
         # reads the one new line we added
         print 'new:', repr(data)
         assert data == newdata
     lf.seek(0)
     assert lf.position() == 0
     assert list(lf) == self.LOG + [newdata]
示例#4
0
 def test_seek(self):
     lf = LogFile(self.fname)
     for data in lf:
         print repr(data)
     # now we are at the current end, remember position
     pos = lf.position()
     # add new data
     newdata = [
         u'1303333333000000', u'00000003', u'SAVE', u'foo', u'0.0.0.0',
         u'example.org', u'666.666.666', u'', u'comment'
     ]
     lf.add(*newdata)
     # go to position before new data
     lf.seek(pos)
     assert lf.position() == pos
     for data in lf:
         # reads the one new line we added
         print 'new:', repr(data)
         assert data == newdata
     lf.seek(0)
     assert lf.position() == 0
     assert list(lf) == self.LOG + [newdata]