def test_argcomplete(testdir, monkeypatch):
    if (not py.path.local.sysfind('bash')):
        pytest.skip('bash not available')
    script = str(testdir.tmpdir.join('test_argcomplete'))
    pytest_bin = sys.argv[0]
    if ('pytest' not in os.path.basename(pytest_bin)):
        pytest.skip(('need to be run with pytest executable, not %s' % (pytest_bin,)))
    with open(str(script), 'w') as fp:
        fp.write(('COMP_WORDBREAKS="$COMP_WORDBREAKS" %s 8>&1 9>&2' % pytest_bin))
    monkeypatch.setenv('_ARGCOMPLETE', '1')
    monkeypatch.setenv('_ARGCOMPLETE_IFS', '\x0b')
    monkeypatch.setenv('COMP_WORDBREAKS', ' \\t\\n"\\\'><=;|&(:')
    arg = '--fu'
    monkeypatch.setenv('COMP_LINE', ('pytest ' + arg))
    monkeypatch.setenv('COMP_POINT', str(len(('pytest ' + arg))))
    result = testdir.run('bash', str(script), arg)
    if (result.ret == 255):
        pytest.skip('argcomplete not available')
    elif (not result.stdout.str()):
        pytest.skip('bash provided no output, argcomplete not available?')
    else:
        result.stdout.fnmatch_lines(['--funcargs', '--fulltrace'])
    os.mkdir('test_argcomplete.d')
    arg = 'test_argc'
    monkeypatch.setenv('COMP_LINE', ('pytest ' + arg))
    monkeypatch.setenv('COMP_POINT', str(len(('pytest ' + arg))))
    result = testdir.run('bash', str(script), arg)
    result.stdout.fnmatch_lines(['test_argcomplete', 'test_argcomplete.d/'])
def test_argcomplete(testdir, monkeypatch):
    if (not py.path.local.sysfind('bash')):
        pytest.skip('bash not available')
    script = str(testdir.tmpdir.join('test_argcomplete'))
    pytest_bin = sys.argv[0]
    if ('pytest' not in os.path.basename(pytest_bin)):
        pytest.skip(('need to be run with pytest executable, not %s' % (pytest_bin,)))
    with open(str(script), 'w') as fp:
        fp.write(('COMP_WORDBREAKS="$COMP_WORDBREAKS" %s 8>&1 9>&2' % pytest_bin))
    monkeypatch.setenv('_ARGCOMPLETE', '1')
    monkeypatch.setenv('_ARGCOMPLETE_IFS', '\x0b')
    monkeypatch.setenv('COMP_WORDBREAKS', ' \\t\\n"\\\'><=;|&(:')
    arg = '--fu'
    monkeypatch.setenv('COMP_LINE', ('pytest ' + arg))
    monkeypatch.setenv('COMP_POINT', str(len(('pytest ' + arg))))
    result = testdir.run('bash', str(script), arg)
    if (result.ret == 255):
        pytest.skip('argcomplete not available')
    elif (not result.stdout.str()):
        pytest.skip('bash provided no output, argcomplete not available?')
    else:
        result.stdout.fnmatch_lines(['--funcargs', '--fulltrace'])
    os.mkdir('test_argcomplete.d')
    arg = 'test_argc'
    monkeypatch.setenv('COMP_LINE', ('pytest ' + arg))
    monkeypatch.setenv('COMP_POINT', str(len(('pytest ' + arg))))
    result = testdir.run('bash', str(script), arg)
    result.stdout.fnmatch_lines(['test_argcomplete', 'test_argcomplete.d/'])