Beispiel #1
0
def test_execute():
    my_container = docker.run("busybox:1", ["sleep", "infinity"],
                              detach=True,
                              remove=True)
    exec_result = docker.execute(my_container, ["echo", "dodo"])
    assert exec_result == "dodo"
    docker.kill(my_container)
Beispiel #2
0
def test_execute_stream():
    my_container = docker.run("busybox:1", ["sleep", "infinity"],
                              detach=True,
                              remove=True)
    exec_result = list(
        docker.execute(my_container, ["sh", "-c", ">&2 echo dodo"],
                       stream=True))
    assert exec_result == [("stderr", b"dodo\n")]
    docker.kill(my_container)
Beispiel #3
0
def test_diff():
    my_container = docker.run("busybox:1", ["sleep", "infinity"],
                              detach=True,
                              remove=True)

    docker.execute(my_container, ["mkdir", "/some_path"])
    docker.execute(my_container, ["touch", "/some_file"])
    docker.execute(my_container, ["rm", "-rf", "/tmp"])

    diff = docker.diff(my_container)
    assert diff == {"/some_path": "A", "/some_file": "A", "/tmp": "D"}
    docker.kill(my_container)