Skip to content

Commit 55b78ff

Browse files
authored
Merge pull request #4848 from blueyed/fix-test_argcomplete
Fix test_argcomplete: use python -m pytest
2 parents e711a6c + ccab469 commit 55b78ff

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def main():
3333
# fmt: off
3434
extras_require={
3535
"testing": [
36+
"argcomplete",
3637
"hypothesis>=3.56",
3738
"nose",
3839
"requests",

testing/test_parseopt.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,12 @@ def test_argcomplete(testdir, monkeypatch):
299299
if not distutils.spawn.find_executable("bash"):
300300
pytest.skip("bash not available")
301301
script = str(testdir.tmpdir.join("test_argcomplete"))
302-
pytest_bin = sys.argv[0]
303-
if "pytest" not in os.path.basename(pytest_bin):
304-
pytest.skip("need to be run with pytest executable, not {}".format(pytest_bin))
305302

306303
with open(str(script), "w") as fp:
307304
# redirect output from argcomplete to stdin and stderr is not trivial
308305
# http://stackoverflow.com/q/12589419/1307905
309306
# so we use bash
310-
fp.write('COMP_WORDBREAKS="$COMP_WORDBREAKS" %s 8>&1 9>&2' % pytest_bin)
307+
fp.write('COMP_WORDBREAKS="$COMP_WORDBREAKS" python -m pytest 8>&1 9>&2')
311308
# alternative would be exteneded Testdir.{run(),_run(),popen()} to be able
312309
# to handle a keyword argument env that replaces os.environ in popen or
313310
# extends the copy, advantage: could not forget to restore
@@ -323,7 +320,11 @@ def test_argcomplete(testdir, monkeypatch):
323320
# argcomplete not found
324321
pytest.skip("argcomplete not available")
325322
elif not result.stdout.str():
326-
pytest.skip("bash provided no output, argcomplete not available?")
323+
pytest.skip(
324+
"bash provided no output on stdout, argcomplete not available? (stderr={!r})".format(
325+
result.stderr.str()
326+
)
327+
)
327328
else:
328329
result.stdout.fnmatch_lines(["--funcargs", "--fulltrace"])
329330
os.mkdir("test_argcomplete.d")

0 commit comments

Comments
 (0)