Ejemplo n.º 1
0
def test_copy():
    queue = NotifyingQueue()
    assert queue.copy() == []

    queue.put(1)
    assert queue.copy() == [1]
    assert queue.peek() == 1, 'copy must preserve the queue'

    queue.put(2)
    assert queue.copy() == [1, 2], 'copy must preserve the items order'
Ejemplo n.º 2
0
def test_copy():
    queue = NotifyingQueue()
    assert queue.copy() == []

    queue.put(1)
    assert queue.copy() == [1]
    assert queue.peek() == 1, 'copy must preserve the queue'

    queue.put(2)
    assert queue.copy() == [1, 2], 'copy must preserve the items order'
Ejemplo n.º 3
0
def test_queue():
    queue = NotifyingQueue()
    assert queue.copy() == []

    queue.put(1)
    assert queue.copy() == [1]
    assert queue.peek() == 1, "copy must preserve the queue"

    queue.put(2)
    assert queue.copy() == [1, 2], "copy must preserve the items order"
    assert queue.peek() == 1, "copy must preserve the queue"

    assert queue.get() == 1, "get should return first item"
    assert queue.peek() == 2, "get must remove first item"