Example #1
0
def test_check_call_real_fh_stringio():
    stderr = io.StringIO()
    stdout = io.StringIO()
    sh.check_call('echo hello 1>&2 && echo world',
                  stdout=stdout,
                  stderr=stderr)
    assert stderr.getvalue() == 'hello\n'
    assert stdout.getvalue() == 'world\n'
Example #2
0
def test_check_call_noshell3():
    with pytest.raises(FileNotFoundError):
        sh.check_call('notexist', shell=False)
Example #3
0
def test_check_call_timeout():
    ts_start = time.time()
    with pytest.raises(sh.TimeoutExpired):
        sh.check_call('sleep 2', timeout=0.1)
    assert time.time() - ts_start < 0.5
Example #4
0
def test_check_call_noshell1():
    sh.check_call(HELLO_CMD, shell=False)
Example #5
0
def test_check_call_noshell2():
    with pytest.raises(sh.CalledProcessError):
        sh.check_call(EXIT1_CMD, shell=False)
Example #6
0
def test_check_call_pipefail():
    with pytest.raises(sh.CalledProcessError):
        sh.check_call('cat NOTEXIST | cat')
Example #7
0
def test_check_call_obfuscate_pwd():
    # TODO intercept logging
    sh.check_call('echo -P mypass', obfuscate_pwd='mypass')
Example #8
0
def test_check_call_nounset():
    with pytest.raises(sh.CalledProcessError):
        sh.check_call('echo $NOT_EXISTING_VARIABLE')
Example #9
0
def test_check_call_errexit():
    with pytest.raises(sh.CalledProcessError):
        sh.check_call('notexist')
Example #10
0
def test_check_call_quotes():
    sh.check_call("echo 'Hello world!' > /dev/null")
Example #11
0
def test_check_call():
    sh.check_call('echo "Hello world!" > /dev/null')
Example #12
0
def test_check_call_obfuscate_pwd():
    # TODO intercept logging
    sh.check_call("echo -P mypass", obfuscate_pwd="mypass")