[lang-ref] ( get_command_standard_error ) ( python )

def test_get_command_standard_error():
    # subprocess.run(.., check=False), stderr

    r = subprocess.run(['ls', '/no/such/file'], capture_output=True, text=True)
    assert 'no such file' in r.stderr.lower()

    # Note: if check=True, it raises Error
    with pytest.raises(subprocess.CalledProcessError):
        subprocess.run(['ls', '/no/such/file'], capture_output=True, text=True, check=True)