Exemplo n.º 1
0
def test_cat_to_stdout(capsys):
    command = Cat()
    command.set_args(["cat", "Bash-CLI/src/tests/data/example.txt"])
    command.execute()

    expected = "first line\nsecond\n123"
    captured = capsys.readouterr()
    assert captured.out == expected
Exemplo n.º 2
0
def test_cat_from_argument():
    command = Cat()
    output = IOChannel()
    command.set_args(["cat", "Bash-CLI/src/tests/data/example.txt"])
    command.set_output_channel(output)
    command.execute()

    expected = "first line\nsecond\n123"
    assert output.read() == expected
Exemplo n.º 3
0
def test_cat_from_channel():
    command = Cat()
    input = IOChannel()
    input.write("my input")

    output = IOChannel()

    command.set_args(["cat"])
    command.set_output_channel(output)
    command.set_input_channel(input)
    command.execute()

    expected = "my input"
    assert output.read() == expected