File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change
1
+ ``--fulltrace `` is honored with collection errors.
Original file line number Diff line number Diff line change @@ -365,12 +365,14 @@ def collect(self):
365
365
366
366
def repr_failure (self , excinfo ):
367
367
""" represent a collection failure. """
368
- if excinfo .errisinstance (self .CollectError ):
368
+ if excinfo .errisinstance (self .CollectError ) and not self .config .getoption (
369
+ "fulltrace" , False
370
+ ):
369
371
exc = excinfo .value
370
372
return str (exc .args [0 ])
371
373
372
374
# Respect explicit tbstyle option, but default to "short"
373
- # (None. _repr_failure_py defaults to "long" without "fulltrace" option).
375
+ # (_repr_failure_py uses "long" with "fulltrace" option always ).
374
376
tbstyle = self .config .getoption ("tbstyle" , "auto" )
375
377
if tbstyle == "auto" :
376
378
tbstyle = "short"
Original file line number Diff line number Diff line change @@ -1210,6 +1210,28 @@ def test_syntax_error_with_non_ascii_chars(testdir):
1210
1210
result .stdout .fnmatch_lines (["*ERROR collecting*" , "*SyntaxError*" , "*1 error in*" ])
1211
1211
1212
1212
1213
+ def test_collecterror_with_fulltrace (testdir ):
1214
+ testdir .makepyfile ("assert 0" )
1215
+ result = testdir .runpytest ("--fulltrace" )
1216
+ result .stdout .fnmatch_lines (
1217
+ [
1218
+ "collected 0 items / 1 error" ,
1219
+ "" ,
1220
+ "*= ERRORS =*" ,
1221
+ "*_ ERROR collecting test_collecterror_with_fulltrace.py _*" ,
1222
+ "" ,
1223
+ "*/src/_pytest/python.py:*: " ,
1224
+ "_ _ _ _ _ _ _ _ *" ,
1225
+ "" ,
1226
+ "> assert 0" ,
1227
+ "E assert 0" ,
1228
+ "" ,
1229
+ "test_collecterror_with_fulltrace.py:1: AssertionError" ,
1230
+ "*! Interrupted: 1 error during collection !*" ,
1231
+ ]
1232
+ )
1233
+
1234
+
1213
1235
def test_skip_duplicates_by_default (testdir ):
1214
1236
"""Test for issue https://github.com/pytest-dev/pytest/issues/1609 (#1609)
1215
1237
You can’t perform that action at this time.
0 commit comments