Skip to content

Commit

Permalink
Fix tox --help and tox --help-ini shows an error when run o… (tox…
Browse files Browse the repository at this point in the history
…-dev#1539)

* solved tox-dev#1509 tox-dev#1540

* added test for fixed help command

* added changelog

* solved CI error

the problem is with psutil==5.7.0 in pypy .

* solved lint problem 😖

Co-authored-by: nkpro2000sr <[email protected]>
  • Loading branch information
2 people authored and ssbarnea committed Apr 19, 2021
1 parent 49c9d7b commit 7df3277
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Mikhail Kyshtymov
Miro Hrončok
Monty Taylor
Morgan Fainberg
Naveen S R
Nick Douma
Nick Prendergast
Oliver Bestwalter
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/1539.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``tox -h`` and ``tox --hi`` shows an error when run outside a directory with tox support files by :user:`nkpro2000sr`.
2 changes: 2 additions & 0 deletions src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def parseconfig(args, plugins=()):
pm.hook.tox_configure(config=config) # post process config object
break
else:
if option.help or option.helpini:
return config
msg = "tox config file (either {}) not found"
candidates = ", ".join(INFO.CONFIG_CANDIDATES)
feedback(msg.format(candidates), sysexit=not (option.help or option.helpini))
Expand Down
16 changes: 14 additions & 2 deletions tests/unit/test_z_cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,32 @@ def test_getvenv(self, initproj):
def test_notoxini_help_still_works(initproj, cmd):
initproj("example123-0.5", filedefs={"tests": {"test_hello.py": "def test_hello(): pass"}})
result = cmd("-h")
msg = "ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found\n"
assert result.err == msg
assert result.out.startswith("usage: ")
assert any("--help" in l for l in result.outlines), result.outlines
result.assert_success(is_run_test_env=False)


def test_notoxini_noerror_in_help(initproj, cmd):
initproj("examplepro", filedefs={})
result = cmd("-h")
msg = "ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found\n"
assert result.err != msg


def test_notoxini_help_ini_still_works(initproj, cmd):
initproj("example123-0.5", filedefs={"tests": {"test_hello.py": "def test_hello(): pass"}})
result = cmd("--help-ini")
assert any("setenv" in l for l in result.outlines), result.outlines
result.assert_success(is_run_test_env=False)


def test_notoxini_noerror_in_help_ini(initproj, cmd):
initproj("examplepro", filedefs={})
result = cmd("--help-ini")
msg = "ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found\n"
assert result.err != msg


def test_envdir_equals_toxini_errors_out(cmd, initproj):
initproj(
"interp123-0.7",
Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ passenv =
SSL_CERT_FILE
PYTEST_*
PIP_CACHE_DIR
deps = pip >= 19.3.1
deps =
pip >= 19.3.1
extras = testing
commands = pytest \
--cov "{envsitepackagesdir}/tox" \
Expand All @@ -38,6 +39,11 @@ commands = pytest \
-n={env:PYTEST_XDIST_PROC_NR:auto} \
{posargs:.}

[testenv:pypy]
deps =
pip >= 19.3.1
psutil <= 5.6.7

[testenv:docs]
description = invoke sphinx-build to build the HTML docs
basepython = python3.8
Expand Down

0 comments on commit 7df3277

Please sign in to comment.