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'
def test_check_call_noshell3(): with pytest.raises(FileNotFoundError): sh.check_call('notexist', shell=False)
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
def test_check_call_noshell1(): sh.check_call(HELLO_CMD, shell=False)
def test_check_call_noshell2(): with pytest.raises(sh.CalledProcessError): sh.check_call(EXIT1_CMD, shell=False)
def test_check_call_pipefail(): with pytest.raises(sh.CalledProcessError): sh.check_call('cat NOTEXIST | cat')
def test_check_call_obfuscate_pwd(): # TODO intercept logging sh.check_call('echo -P mypass', obfuscate_pwd='mypass')
def test_check_call_nounset(): with pytest.raises(sh.CalledProcessError): sh.check_call('echo $NOT_EXISTING_VARIABLE')
def test_check_call_errexit(): with pytest.raises(sh.CalledProcessError): sh.check_call('notexist')
def test_check_call_quotes(): sh.check_call("echo 'Hello world!' > /dev/null")
def test_check_call(): sh.check_call('echo "Hello world!" > /dev/null')
def test_check_call_obfuscate_pwd(): # TODO intercept logging sh.check_call("echo -P mypass", obfuscate_pwd="mypass")