示例#1
0
def test_read_backup():
    p = Pipeline()
    p.add("foo")
    assert (p.read(2) == "fo")
    p.backup("fo")
    assert (p.read(2) == "fo")
    assert (p.read(2) == "o")
示例#2
0
def test_long_1():
    p = Pipeline()
    p.add("foo")
    assert (p.read(2) == "fo")
    p.add("bar")
    assert (p.read(3) == "oba")
    p.backup("rocko")
    p.add(StringIO("soma"))
    assert (p.read(1000) == "rockorsoma")
    assert (p.read(1000) == "")
    assert (p.empty)
    p.add("X" * 10000)
    p.close_request()
    assert (p.read(5000) == 'X' * 5000)
    p.backup('XXX')
    try:
        p.add("newstuff")
    except PipelineClosed:
        pass
    assert (not p.empty)
    assert (p.read(100000) == 'X' * 5003)
    assert (not p.empty)
    try:
        p.read(1000)
    except PipelineCloseRequest:
        pass
    assert (not p.empty)
    try:
        p.read(1000)
    except PipelineCloseRequest:
        pass
def test_read_backup():
    p = Pipeline()
    p.add("foo")
    WVPASS(p.read(2) == "fo")
    p.backup("fo")
    WVPASS(p.read(2) == "fo")
    WVPASS(p.read(2) == "o")
示例#4
0
 def test_read_backup(self):
     p = Pipeline()
     p.add("foo")
     assert p.read(2) == "fo"
     p.backup("fo")
     assert p.read(2) == "fo"
     assert p.read(2) == "o"
示例#5
0
def test_read_hybrid_objects():
    p = Pipeline()
    p.add("foo,")
    p.add(StringIO("bar,"))
    p.add(open(FILE))

    assert (p.read(10) == "foo,bar,#1")
    assert (p.read(4) == "2345")
    p.backup("rock") # in the middle of the "file"
    assert (p.read(6) == "rock67")
def test_long_1():
    p = Pipeline()
    p.add("foo")
    WVPASS(p.read(2) == "fo")
    p.add("bar")
    WVPASS(p.read(3) == "oba")
    p.backup("rocko")
    p.add(StringIO("soma"))
    WVPASS(p.read(1000) == "rockorsoma")
    WVPASS(p.read(1000) == "")
    WVPASS(p.empty)
    p.add("X" * 10000)
    p.close_request()
    WVPASS(p.read(5000) == 'X' * 5000)
    p.backup('XXX')
    WVEXCEPT(PipelineClosed, p.add, "newstuff")
    WVPASS(not p.empty)
    WVPASS(p.read(100000) == 'X' * 5003)
    WVPASS(not p.empty)
    WVEXCEPT(PipelineCloseRequest, p.read, 1000)
    WVPASS(not p.empty)
    WVEXCEPT(PipelineCloseRequest, p.read, 1000)
示例#7
0
 def test_long_1(self):
     p = Pipeline()
     p.add("foo")
     assert p.read(2) == "fo"
     p.add("bar")
     assert p.read(3) == "oba"
     p.backup("rocko")
     p.add(StringIO("soma"))
     assert p.read(1000) == "rockorsoma"
     assert p.read(1000) == ""
     assert p.empty
     p.add("X" * 10000)
     p.close_request()
     assert p.read(5000) == 'X' * 5000
     p.backup('XXX')
     py.test.raises(PipelineClosed, p.add, "newstuff")
     assert not p.empty
     assert p.read(100000) == 'X' * 5003
     assert not p.empty
     py.test.raises(PipelineCloseRequest, p.read, 1000)
     assert not p.empty
     py.test.raises(PipelineCloseRequest, p.read, 1000)
示例#8
0
def test_read_backup_extra():
    p = Pipeline()
    p.add("foo")
    assert (p.read(2) == "fo")
    p.backup("foobar")
    assert (p.read(500) == "foobaro")