From 537f26c267f08b35c250893e3c91586fe58076fe Mon Sep 17 00:00:00 2001 From: NAVEEN S R <56086391+nkpro2000sr@users.noreply.github.com> Date: Sun, 22 Mar 2020 23:29:46 +0530 Subject: =?UTF-8?q?Fix=20`tox=20--help`=20and=20`tox=20--help-ini`=20shows?= =?UTF-8?q?=20an=20error=20when=20run=20o=E2=80=A6=20(#1539)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * solved #1509 #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 :confounded: Co-authored-by: nkpro2000sr --- CONTRIBUTORS | 1 + docs/changelog/1539.bugfix.rst | 1 + src/tox/config/__init__.py | 2 ++ tests/unit/test_z_cmdline.py | 16 ++++++++++++++-- tox.ini | 8 +++++++- 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 docs/changelog/1539.bugfix.rst diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 21be9edf..3449b12d 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -65,6 +65,7 @@ Mikhail Kyshtymov Miro HronĨok Monty Taylor Morgan Fainberg +Naveen S R Nick Douma Nick Prendergast Oliver Bestwalter diff --git a/docs/changelog/1539.bugfix.rst b/docs/changelog/1539.bugfix.rst new file mode 100644 index 00000000..51875f13 --- /dev/null +++ b/docs/changelog/1539.bugfix.rst @@ -0,0 +1 @@ +Fix ``tox -h`` and ``tox --hi`` shows an error when run outside a directory with tox support files by :user:`nkpro2000sr`. diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index f6b34844..922e3bc5 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -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)) diff --git a/tests/unit/test_z_cmdline.py b/tests/unit/test_z_cmdline.py index 71d2d796..03246dcb 100644 --- a/tests/unit/test_z_cmdline.py +++ b/tests/unit/test_z_cmdline.py @@ -84,13 +84,18 @@ class TestSession: 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") @@ -98,6 +103,13 @@ def test_notoxini_help_ini_still_works(initproj, cmd): 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", diff --git a/tox.ini b/tox.ini index 9b2c2b86..4e4f52b1 100644 --- a/tox.ini +++ b/tox.ini @@ -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" \ @@ -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 -- cgit v1.2.1