예제 #1
0
def test_chained_procs():
    ls = Process('ls {test_dir}'.format(test_dir=TEST_DIR))
    grep = Process('grep 2')
    chain = ls | grep
    chain.run()
    assert chain.returncode == 0
    assert chain.stdout.strip() == 'file2'
예제 #2
0
def test_multi_chained_procs():
    ls = Process('ls {test_dir}'.format(test_dir=TEST_DIR))
    grep = Process('grep 2')
    wc = Process('wc -c')
    chain = ls | grep | wc
    chain.run()
    assert chain.returncode == 0
    assert chain.stdout.strip() == '6'
예제 #3
0
def tests_repr():
    p = Process('foo')
    assert repr(p) == '<Process: foo>'
예제 #4
0
def test_not_ok_if_returncode_not_0():
    assert not os.path.exists('/bin/nosuchcommand')
    p = Process('/bin/nosuchcommand')
    p.run()
    assert p.ok is False
예제 #5
0
def test_ok_if_returncode_0():
    p = Process('ls')
    p.run()
    assert p.ok is True
예제 #6
0
def test_returncode():
    assert not os.path.exists('/bin/nosuchcommand')

    p = Process('/bin/nosuchcommand')
    p.run()
    assert p.returncode == 127
예제 #7
0
def test_empty_output():
    cat = Process('cat /dev/null')
    cat.run()
    assert cat.stdout == u''
예제 #8
0
def test_single_proc():
    ls = Process('ls {test_dir}'.format(test_dir=TEST_DIR))
    ls.run()
    assert ls.returncode == 0
    assert ls.stdout == u'file1\nfile2\nfile3\n'
예제 #9
0
def test_not_ok_if_returncode_not_0():
    assert not os.path.exists('/bin/nosuchcommand')
    p = Process('/bin/nosuchcommand')
    p.run()
    assert p.ok is False
예제 #10
0
def test_ok_if_returncode_0():
    p = Process('ls')
    p.run()
    assert p.ok is True
예제 #11
0
def test_returncode():
    assert not os.path.exists('/bin/nosuchcommand')

    p = Process('/bin/nosuchcommand')
    p.run()
    assert p.returncode == 127
예제 #12
0
def test_empty_output():
    cat = Process('cat /dev/null')
    cat.run()
    assert cat.stdout == u''
예제 #13
0
def test_single_proc():
    ls = Process('ls {test_dir}'.format(test_dir=TEST_DIR))
    ls.run()
    assert ls.returncode == 0
    assert ls.stdout == u'file1\nfile2\nfile3\n'