summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNAVEEN S R <56086391+nkpro2000sr@users.noreply.github.com>2020-03-22 23:29:46 +0530
committerGitHub <noreply@github.com>2020-03-22 17:59:46 +0000
commit537f26c267f08b35c250893e3c91586fe58076fe (patch)
tree2ad3e7e95fb42b3a8108caeec3fd2eff49a2d9fb
parent330599f2979e1e4a5e1757423f76c56de63d27d2 (diff)
downloadtox-git-537f26c267f08b35c250893e3c91586fe58076fe.tar.gz
Fix `tox --help` and `tox --help-ini` shows an error when run o… (#1539)
* 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 <naveennotes2000sr@gmail.com>
-rw-r--r--CONTRIBUTORS1
-rw-r--r--docs/changelog/1539.bugfix.rst1
-rw-r--r--src/tox/config/__init__.py2
-rw-r--r--tests/unit/test_z_cmdline.py16
-rw-r--r--tox.ini8
5 files changed, 25 insertions, 3 deletions
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