diff options
author | NAVEEN S R <56086391+nkpro2000sr@users.noreply.github.com> | 2020-03-27 01:41:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-27 08:41:44 +0000 |
commit | f0e66bfbc618e16aecece2aacb167fd56730eff5 (patch) | |
tree | 9583288e9ed8151d2e40696da7f830c8bcab3523 | |
parent | 3f7eb98d2225982c8c1bcff6f751636356d8b398 (diff) | |
download | tox-git-f0e66bfbc618e16aecece2aacb167fd56730eff5.tar.gz |
Fixed irrelevant Error message for invalid argument when runnin… (#1547)
* Fixed #1546
* Added Changelog
* Solved CI Failure
-rw-r--r-- | docs/changelog/1547.bugfix.rst | 1 | ||||
-rw-r--r-- | src/tox/config/__init__.py | 5 | ||||
-rw-r--r-- | tests/unit/test_z_cmdline.py | 19 |
3 files changed, 25 insertions, 0 deletions
diff --git a/docs/changelog/1547.bugfix.rst b/docs/changelog/1547.bugfix.rst new file mode 100644 index 00000000..c4b2248e --- /dev/null +++ b/docs/changelog/1547.bugfix.rst @@ -0,0 +1 @@ +Fix irrelevant Error message for invalid argument when running 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 922e3bc5..85e99185 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -270,6 +270,11 @@ def parseconfig(args, plugins=()): pm.hook.tox_configure(config=config) # post process config object break else: + parser = Parser() + pm.hook.tox_addoption(parser=parser) + # if no tox config file, now we need do a strict argument evaluation + # raise on unknown args + parser.parse_cli(args, strict=True) if option.help or option.helpini: return config msg = "tox config file (either {}) not found" diff --git a/tests/unit/test_z_cmdline.py b/tests/unit/test_z_cmdline.py index 03246dcb..e809f1d7 100644 --- a/tests/unit/test_z_cmdline.py +++ b/tests/unit/test_z_cmdline.py @@ -110,6 +110,25 @@ def test_notoxini_noerror_in_help_ini(initproj, cmd): assert result.err != msg +def test_unrecognized_arguments_error(initproj, cmd): + initproj( + "examplepro1", + filedefs={ + "tests": {"test_hello.py": "def test_hello(): pass"}, + "tox.ini": """ + [testenv:hello] + [testenv:world] + """, + }, + ) + result1 = cmd("--invalid-argument") + withtoxini = result1.err + initproj("examplepro2", filedefs={}) + result2 = cmd("--invalid-argument") + notoxini = result2.err + assert withtoxini == notoxini + + def test_envdir_equals_toxini_errors_out(cmd, initproj): initproj( "interp123-0.7", |