forked from thobbs/multitail-curses
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
35 lines (26 loc) · 1012 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import unittest
from tempfile import TemporaryFile as temp
from nose.tools import assert_equal
import multitail
class TestSeeking(unittest.TestCase):
def test_basic(self):
with temp() as f:
for i in range(10):
f.write("%d\n" % i)
for i in range(10):
multitail._seek_to_n_lines_from_end(f, i)
assert_equal(i, len(f.readlines()))
def test_short_file(self):
""" The file is shorter than the number of lines we request """
with temp() as f:
for i in range(3):
f.write("%d\n" % i)
multitail._seek_to_n_lines_from_end(f, 100)
assert_equal(3, len(f.readlines()))
def test_multiple_buffers(self):
""" We need to buffer multiple times """
with temp() as f:
for i in range(10000):
f.write("%d\n" % i)
multitail._seek_to_n_lines_from_end(f, 5000)
assert_equal(5000, len(f.readlines()))