pytest 3.6.3 on Debian 9.5 (though, I'm running in Docker and can repro on CentOS 7)
This example from StackOverflow captures what I'd like to do:
================================================================= FAILURES =================================================================
____________________________________________________ test_check_default_content_for_user ___________________________________________________
test_data = {'amount_of_number_of_days_options': 6, 'available_for_guest': 'True', 'fl_password': 'password', 'fl_user': '[email protected]', ...}
When a test fails/errors, I want the full fixture value to be shown (i.e. no ...).
No combination of --tb long, -v, --full-trace, or --showlocals that I've tried has worked.
Is there a way to do this?
GitMate.io thinks possibly related issues are https://github.com/pytest-dev/pytest/issues/1392 (Idea: make FixtureLookupError show prettier fixture list), https://github.com/pytest-dev/pytest/issues/833 (--fixtures only shows fixtures from first file), https://github.com/pytest-dev/pytest/issues/351 (Show repr() of exceptions passed to @parametrize), https://github.com/pytest-dev/pytest/issues/2934 (capsysbinary fixture), and https://github.com/pytest-dev/pytest/issues/3377 (Rescope a fixture).
i would suggest to pretty-print it yourself
this code is precisely in place to avoid massive objects destroying all sensible reading of the output (because after a certain size we have no way safely figure if it is still barely ok or not)
what could-be done is increasing the limit with verbosity however
what could-be done is increasing the limit with verbosity however
That would be greatly preferred as we have thousands of tests that would need revision otherwise.
Is the threshold for shortening the repr with ... hard-coded somewhere in the PyTest code?
If yes, could this somehow be provided as option in pytest.ini or something like that?
Looks like this is the relevant code:
https://github.com/pytest-dev/pytest/blob/5903f4596a6394be4ffb534451a6af4af459fc34/src/_pytest/_code/code.py#L622-L630
py.io.saferepr is the call that does the shortening:
https://github.com/pytest-dev/py/blob/b9da2ed6178cd37d4ed6b41f9fa8234dce96973f/py/_io/saferepr.py#L53-L57
It takes a maxsize parameter; however, it only seems to allow tightening:
(Pdb) pp type(obj), len(obj)
(<class 'dict'>, 1000)
(Pdb) pp py.io.saferepr(obj)
'{0: 6009, 1: 6010, 2: 6011, 3: 6012, ...}'
(Pdb) pp py.io.saferepr(obj, maxsize=10)
'{0:......}'
(Pdb) pp py.io.saferepr(obj, maxsize=100)
'{0: 6017, 1: 6018, 2: 6019, 3: 6020, ...}'
(Pdb) pp py.io.saferepr(obj, maxsize=1000)
'{0: 6021, 1: 6022, 2: 6023, 3: 6024, ...}'
(Pdb) pp py.io.saferepr(obj, maxsize=10000)
'{0: 6025, 1: 6026, 2: 6027, 3: 6028, ...}'
I think py.io.safrepr would need to set other Repr.max* attributes:
https://github.com/pytest-dev/py/blob/b9da2ed6178cd37d4ed6b41f9fa8234dce96973f/py/_io/saferepr.py#L68-L70
There's an internal "truncate_locals" option that gets used with -vv, and enables skipping of truncation with -l. Via https://github.com/pytest-dev/pytest/pull/3681.
I'm still seeing this issue with Pytest 4.6.6 (looks like #3681 is in 3.7.0, so should be included)... Am I understanding correctly that I should only need to pass -vv -l?
edit: Oh wow, nevermind... The locals appear _below_ the failure.