minor adjustment, added test for positional argument completion
--HG-- branch : argcomplete
This commit is contained in:
parent
87860600fb
commit
6817a56270
|
@ -55,7 +55,6 @@ if os.environ.get('_ARGCOMPLETE'):
|
||||||
if sys.version_info[:2] < (2, 6):
|
if sys.version_info[:2] < (2, 6):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
import argcomplete
|
|
||||||
import argcomplete.completers
|
import argcomplete.completers
|
||||||
except ImportError:
|
except ImportError:
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
|
@ -175,10 +175,10 @@ def test_addoption_parser_epilog(testdir):
|
||||||
|
|
||||||
@pytest.mark.skipif("sys.version_info < (2,5)")
|
@pytest.mark.skipif("sys.version_info < (2,5)")
|
||||||
def test_argcomplete(testdir):
|
def test_argcomplete(testdir):
|
||||||
|
if not py.path.local.sysfind('bash'):
|
||||||
|
pytest.skip("bash not available")
|
||||||
import os
|
import os
|
||||||
p = py.path.local.make_numbered_dir(prefix="test_argcomplete-",
|
script = os.path.join(os.getcwd(), 'test_argcomplete')
|
||||||
keep=None, rootdir=testdir.tmpdir)
|
|
||||||
script = p._fastjoin('test_argcomplete')
|
|
||||||
with open(str(script), 'w') as fp:
|
with open(str(script), 'w') as fp:
|
||||||
# redirect output from argcomplete to stdin and stderr is not trivial
|
# redirect output from argcomplete to stdin and stderr is not trivial
|
||||||
# http://stackoverflow.com/q/12589419/1307905
|
# http://stackoverflow.com/q/12589419/1307905
|
||||||
|
@ -187,14 +187,22 @@ def test_argcomplete(testdir):
|
||||||
'8>&1 9>&2')
|
'8>&1 9>&2')
|
||||||
os.environ['_ARGCOMPLETE'] = "1"
|
os.environ['_ARGCOMPLETE'] = "1"
|
||||||
os.environ['_ARGCOMPLETE_IFS'] = "\x0b"
|
os.environ['_ARGCOMPLETE_IFS'] = "\x0b"
|
||||||
os.environ['COMP_LINE'] = "py.test --fu"
|
|
||||||
os.environ['COMP_POINT'] = "12"
|
|
||||||
os.environ['COMP_WORDBREAKS'] = ' \\t\\n"\\\'><=;|&(:'
|
os.environ['COMP_WORDBREAKS'] = ' \\t\\n"\\\'><=;|&(:'
|
||||||
|
|
||||||
result = testdir.run('bash', str(script), '--fu')
|
arg = '--fu'
|
||||||
|
os.environ['COMP_LINE'] = "py.test " + arg
|
||||||
|
os.environ['COMP_POINT'] = str(len(os.environ['COMP_LINE']))
|
||||||
|
result = testdir.run('bash', str(script), arg)
|
||||||
print dir(result), result.ret
|
print dir(result), result.ret
|
||||||
if result.ret == 255:
|
if result.ret == 255:
|
||||||
# argcomplete not found
|
# argcomplete not found
|
||||||
assert True
|
pytest.skip("argcomplete not available")
|
||||||
else:
|
else:
|
||||||
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
|
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
|
||||||
|
|
||||||
|
os.mkdir('test_argcomplete.d')
|
||||||
|
arg = 'test_argc'
|
||||||
|
os.environ['COMP_LINE'] = "py.test " + arg
|
||||||
|
os.environ['COMP_POINT'] = str(len(os.environ['COMP_LINE']))
|
||||||
|
result = testdir.run('bash', str(script), arg)
|
||||||
|
result.stdout.fnmatch_lines(["test_argcomplete", "test_argcomplete.d/"])
|
||||||
|
|
Loading…
Reference in New Issue