Exemplo n.º 1
0
def test_change_limit_then_chunk():
    data = "foo\n" * 200
    m = MoreLimiter(1)
    chunks = m.chunk(data)
    m.change_limit(10)
    for _ in xrange(20):
        assert chunks.next() == ("foo\n" * 10)
Exemplo n.º 2
0
def test_empty_then_chunk():
    data = "foo"
    m = MoreLimiter(10)
    chunks = m.chunk(data)
    assert chunks.next() == data
    data = "bar"
    chunks = m.chunk(data)
    assert chunks.next() == data
Exemplo n.º 3
0
def test_basic_more():
    data = "foo\n" * 200
    m = MoreLimiter(10)
    chunks = m.chunk(data)
    for _ in xrange(20):
        res = chunks.next()
        expected = ("foo\n" * 10)
        print repr(expected)
        assert res == expected
    assert chunks.next() == ''
Exemplo n.º 4
0
def test_clearfeed_raise():
    data = "foo"
    m = MoreLimiter(10)
    chunks = m.chunk(data)
    assert chunks.next() == data
    try:
        chunks.next()
    except StopIteration:
        pass
    else:
        assert False
Exemplo n.º 5
0
def test_reported_length():
    data = "foo\n" * 499
    m = MoreLimiter(10)
    chunks = m.chunk(data)
    assert chunks.initial_lines == 500  #plus the emptiness at the end.
    assert chunks.next() == ("foo\n" * 10)
    assert chunks.lines_left == 490
    m.change_limit(5)
    assert chunks.initial_lines == 500
    assert chunks.next() == ("foo\n" * 5)
    assert chunks.lines_left == 485
Exemplo n.º 6
0
def test_empty_error_then_chunk():
    data = "foo"
    m = MoreLimiter(10)
    chunks = m.chunk(data)
    assert chunks.next() == data
    try:
        chunks.next()
    except StopIteration:
        pass
    else:
        assert False
    data = "bar"
    chunks = m.chunk(data)
    assert chunks.next() == data
Exemplo n.º 7
0
def test_multiple_chunkage():
    data = "foo"
    m = MoreLimiter(10)
    m.chunk("bar")
    chunks = m.chunk(data)
    assert chunks.next() == data
Exemplo n.º 8
0
def test_shorter_than_capacity():
    data = "foo"
    m = MoreLimiter(10)
    chunks = m.chunk(data)
    assert chunks.next() == data
Exemplo n.º 9
0
 def setUp(self):
     self.obj = MUDObject(None)
     self.obj.more_limiter = MoreLimiter(10)
     self.setup_for_object(self.obj)
Exemplo n.º 10
0
def more_limiter(self):
    return MoreLimiter(20)