Пример #1
0
class TestRingBuffer(TestCase):
    def setUp(self):
        self.b = RingBuffer([], maxlen=5)

    def test_append_empty(self):
        self.b.append('x')
        eq_(self.b, ['x'])

    def test_append_full(self):
        self.b.extend("abcde")
        self.b.append('f')
        eq_(self.b, ['b', 'c', 'd', 'e', 'f'])

    def test_extend_empty(self):
        self.b.extend("abc")
        eq_(self.b, ['a', 'b', 'c'])

    def test_extend_overrun(self):
        self.b.extend("abc")
        self.b.extend("defg")
        eq_(self.b, ['c', 'd', 'e', 'f', 'g'])

    def test_extend_full(self):
        self.b.extend("abcde")
        self.b.extend("fgh")
        eq_(self.b, ['d', 'e', 'f', 'g', 'h'])
Пример #2
0
class TestRingBuffer(TestCase):
    def setUp(self):
        self.b = RingBuffer([], maxlen=5)

    def test_append_empty(self):
        self.b.append('x')
        eq_(self.b, ['x'])

    def test_append_full(self):
        self.b.extend("abcde")
        self.b.append('f')
        eq_(self.b, ['b', 'c', 'd', 'e', 'f'])

    def test_extend_empty(self):
        self.b.extend("abc")
        eq_(self.b, ['a', 'b', 'c'])

    def test_extend_overrun(self):
        self.b.extend("abc")
        self.b.extend("defg")
        eq_(self.b, ['c', 'd', 'e', 'f', 'g'])

    def test_extend_full(self):
        self.b.extend("abcde")
        self.b.extend("fgh")
        eq_(self.b, ['d', 'e', 'f', 'g', 'h'])
Пример #3
0
class TestRingBuffer(TestCase):
    def setUp(self):
        self.b = RingBuffer([], maxlen=5)

    def test_append_empty(self):
        self.b.append('x')
        eq_(self.b, ['x'])

    def test_append_full(self):
        self.b.extend("abcde")
        self.b.append('f')
        eq_(self.b, ['b', 'c', 'd', 'e', 'f'])

    def test_extend_empty(self):
        self.b.extend("abc")
        eq_(self.b, ['a', 'b', 'c'])

    def test_extend_overrun(self):
        self.b.extend("abc")
        self.b.extend("defg")
        eq_(self.b, ['c', 'd', 'e', 'f', 'g'])

    def test_extend_full(self):
        self.b.extend("abcde")
        self.b.extend("fgh")
        eq_(self.b, ['d', 'e', 'f', 'g', 'h'])

    def test_plus_equals(self):
        self.b += "abcdefgh"
        eq_(self.b, ['d', 'e', 'f', 'g', 'h'])

    def test_oversized_extend(self):
        self.b.extend("abcdefghijklmn")
        eq_(self.b, ['j', 'k', 'l', 'm', 'n'])

    def test_zero_maxlen_append(self):
        b = RingBuffer([], maxlen=0)
        b.append('a')
        eq_(b, [])

    def test_zero_maxlen_extend(self):
        b = RingBuffer([], maxlen=0)
        b.extend('abcdefghijklmnop')
        eq_(b, [])

    def test_None_maxlen_append(self):
        b = RingBuffer([], maxlen=None)
        b.append('a')
        eq_(b, ['a'])

    def test_None_maxlen_extend(self):
        b = RingBuffer([], maxlen=None)
        b.extend('abcdefghijklmnop')
        eq_(''.join(b), 'abcdefghijklmnop')
Пример #4
0
class TestRingBuffer(TestCase):
    def setUp(self):
        self.b = RingBuffer([], maxlen=5)

    def test_append_empty(self):
        self.b.append('x')
        eq_(self.b, ['x'])

    def test_append_full(self):
        self.b.extend("abcde")
        self.b.append('f')
        eq_(self.b, ['b', 'c', 'd', 'e', 'f'])

    def test_extend_empty(self):
        self.b.extend("abc")
        eq_(self.b, ['a', 'b', 'c'])

    def test_extend_overrun(self):
        self.b.extend("abc")
        self.b.extend("defg")
        eq_(self.b, ['c', 'd', 'e', 'f', 'g'])

    def test_extend_full(self):
        self.b.extend("abcde")
        self.b.extend("fgh")
        eq_(self.b, ['d', 'e', 'f', 'g', 'h'])

    def test_plus_equals(self):
        self.b += "abcdefgh"
        eq_(self.b, ['d', 'e', 'f', 'g', 'h'])

    def test_oversized_extend(self):
        self.b.extend("abcdefghijklmn")
        eq_(self.b, ['j', 'k', 'l', 'm', 'n'])

    def test_zero_maxlen_append(self):
        b = RingBuffer([], maxlen=0)
        b.append('a')
        eq_(b, [])

    def test_zero_maxlen_extend(self):
        b = RingBuffer([], maxlen=0)
        b.extend('abcdefghijklmnop')
        eq_(b, [])

    def test_None_maxlen_append(self):
        b = RingBuffer([], maxlen=None)
        b.append('a')
        eq_(b, ['a'])

    def test_None_maxlen_extend(self):
        b = RingBuffer([], maxlen=None)
        b.extend('abcdefghijklmnop')
        eq_(''.join(b), 'abcdefghijklmnop')
Пример #5
0
 def test_None_maxlen_append(self):
     b = RingBuffer([], maxlen=None)
     b.append('a')
     eq_(b, ['a'])
Пример #6
0
 def test_zero_maxlen_append(self):
     b = RingBuffer([], maxlen=0)
     b.append('a')
     eq_(b, [])
Пример #7
0
 def test_None_maxlen_append(self):
     b = RingBuffer([], maxlen=None)
     b.append('a')
     eq_(b, ['a'])
Пример #8
0
 def test_zero_maxlen_append(self):
     b = RingBuffer([], maxlen=0)
     b.append('a')
     eq_(b, [])