Pytest: "-l" does not dump variables where "--tb" is not "long"

Created on 31 Mar 2014  路  15Comments  路  Source: pytest-dev/pytest

Originally reported by: Ionel Cristian M膬rie葯 (BitBucket: ionelmc, GitHub: ionelmc)


Example output

    > assert hist == ['before', 'the-return-valuex', 'after', 'finally', 'closed']
    E assert ['before', 't...ly', 'closed'] == ['before', 'th...ly', 'closed']
    E At index 1 diff: 'the-return-value' != 'the-return-valuex'

I use these options:

 -rxEfsl
--strict
--ignore docs/conf.py
--ignore setup.py
--doctest-modules
--doctest-glob \*.rst
--tb short

tracebacks bug

All 15 comments

_Original comment by_ Ionel Cristian M膬rie葯 (BitBucket: ionelmc, GitHub: ionelmc):


I would expect to have the value of hist shown.

_Original comment by_ Ionel Cristian M膬rie葯 (BitBucket: ionelmc, GitHub: ionelmc):


I have also tried -l but it does not help - there's no traceback, it's just a failed assertion.

_Original comment by_ Floris Bruynooghe (BitBucket: flub, GitHub: flub):


This should probably behave similarly to how diffs and dicts work: it should show a hint that you can get the full diff using -v and then that should also be implemented.

_Original comment by_ Ionel Cristian M膬rie葯 (BitBucket: ionelmc, GitHub: ionelmc):


Seems --tb short makes the difference.

I would stop using it but the default tracebacks are ridiculously huge, I can't even see where they start ...

_Original comment by_ Ionel Cristian M膬rie葯 (BitBucket: ionelmc, GitHub: ionelmc):


@flub I think this is a bug, only --tb long works with -l.

_Original comment by_ Floris Bruynooghe (BitBucket: flub, GitHub: flub):


Err, I'm not so sure about your classification as bug and title re-naming. This issue was about seeing the full lists when comparing two lists. Now you've confused it with something which is potentially an other issue: -l/--tb=short interaction. If the latter is an issue it should be discussed in a separate report rather then hijack this one.

_Original comment by_ Ionel Cristian M膬rie葯 (BitBucket: ionelmc, GitHub: ionelmc):


I'm sorry, I thought I created this issue ...

_Original comment by_ Floris Bruynooghe (BitBucket: flub, GitHub: flub):


Sorry, hijacking is probably a big word. It just seemed to me like the original report was a totally different report, so now I just don't know if you still care about the assert repr of lists or not.

On whether -l/--tb=short should work together or not I'm not in a position to say and would wait for someone else's opinion.

thoughts on making --showlocals + --tb= anything but long / auto an error? I could write up a PR for this to features

CC @nicoddemus @blueyed

It could be useful with other styles, e.g. short: https://github.com/pytest-dev/pytest/issues/1715.

thoughts on making --showlocals + --tb= anything but long / auto an error? I could write up a PR for this to features

It could be useful with other styles, e.g. short: #1715.

+1 for making showlocals work with short. There's no reason to disable showlocals for --tb=short, it looks like a clear bug. The code comment here also indicates this wasn't intended, showlocals should only be disable for --tb=native.

Found this issue because we ran into the same problem for SciPy at https://github.com/scipy/scipy/pull/11282

@blueyed @nicoddemus is this bug not getting attention because it's low-prio, or because of the confusing description/history in the comments here? If the latter, I can open a new bug if it helps.

@rgommers no reason -- there's 480+ issues in the backlog currently -- would you like to take a stab at a PR to enable this?

Allowing --showlocals with --tb=short seems simple: #6384

thanks @pv!

Was this page helpful?
0 / 5 - 0 ratings