Skip to content

Commit e86e835

Browse files
committed
WIP
1 parent e712adc commit e86e835

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/_pytest/fixtures.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,9 @@ def scope2index(scope, descr, where=None):
698698
try:
699699
return scopes.index(scope)
700700
except ValueError:
701-
raise ValueError(
701+
from _pytest.config import UsageError
702+
703+
raise UsageError(
702704
"{} {}has an unsupported scope value '{}'".format(
703705
descr, "from {} ".format(where) if where else "", scope
704706
)

src/_pytest/runner.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,18 @@ def pytest_runtest_makereport(item, call):
227227
outcome = "passed"
228228
longrepr = None
229229
else:
230+
from _pytest.config import UsageError
231+
230232
if not isinstance(excinfo, ExceptionInfo):
231233
outcome = "failed"
232234
longrepr = excinfo
233235
elif excinfo.errisinstance(skip.Exception):
234236
outcome = "skipped"
235237
r = excinfo._getreprcrash()
236238
longrepr = (str(r.path), r.lineno, r.message)
239+
elif excinfo.errisinstance(UsageError) and item.config.getoption("verbose") < 2:
240+
outcome = "failed"
241+
longrepr = six.text_type(excinfo.value)
237242
else:
238243
outcome = "failed"
239244
if call.when == "call":
@@ -264,9 +269,16 @@ def pytest_make_collect_report(collector):
264269
outcome = "passed"
265270
else:
266271
from _pytest import nose
272+
from _pytest.config import UsageError
267273

268274
skip_exceptions = (Skipped,) + nose.get_skip_exceptions()
269-
if call.excinfo.errisinstance(skip_exceptions):
275+
if (
276+
call.excinfo.errisinstance(UsageError)
277+
and collector.config.getoption("verbose") < 2
278+
):
279+
outcome = "failed"
280+
longrepr = six.text_type(call.excinfo.value)
281+
elif call.excinfo.errisinstance(skip_exceptions):
270282
outcome = "skipped"
271283
r = collector._repr_failure_py(call.excinfo, "line").reprcrash
272284
longrepr = (str(r.path), r.lineno, r.message)

0 commit comments

Comments
 (0)