Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'assert_truncate_level' to show the full diff without -vv #10588

Conversation

Pierre-Sassoulas
Copy link
Contributor

Add an option to get the full diff regardless of the verbosity.

This would Closes #3962

Co-authored-by: Daniel Hahler github@thequod.de (expanded from it and adapted from the fork. I kept the option name but changing it wouldn't be that hard).

Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @Pierre-Sassoulas, we really appreciate it!

As for the option name, assert_truncate_level reads strange to me, given assert is a verb. Perhaps we should use assertion_truncate_level? I'm not a native English speaker, so would appreciate if others share their opinions.

@@ -270,6 +270,10 @@ situations, for example you are shown even fixtures that start with ``_`` if you
Using higher verbosity levels (``-vvv``, ``-vvvv``, ...) is supported, but has no effect in pytest itself at the moment,
however some plugins might make use of higher verbosity.

By default for verbosity inferior to ``-vv`` really long output are truncated. It's also possible to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, but in addition to this, we should also include this option in the Configuration Options section in reference.rst, making use of the confval directive, for example:

.. confval:: addopts
Add the specified ``OPTS`` to the set of command line arguments as if they
had been specified by the user. Example: if you have this ini file content:

(Make sure to include the new option in alphabetical order)

doc/en/how-to/output.rst Show resolved Hide resolved
@@ -0,0 +1 @@
``assert_truncate_level`` option added to be able to get the full diff without using ``-vv``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using confval as I mentioned before, we can create a link to it automatically:

Suggested change
``assert_truncate_level`` option added to be able to get the full diff without using ``-vv``.
:confval:`assert_truncate_level` option added to be able to get the full diff without using ``-vv``.

@@ -1664,7 +1674,9 @@ def test_raising_repr():
"""
)
result = pytester.runpytest()
result.stdout.fnmatch_lines(["E AssertionError: <exception str() failed>"])
result.stdout.fnmatch_lines(
["E AssertionError: <unprintable AssertionError object>"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should be reverted it seems.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's strange I had an issue locally.

@Pierre-Sassoulas
Copy link
Contributor Author

As for the option name, assert_truncate_level reads strange to me, given assert is a verb. Perhaps we should use assertion_truncate_level?

I agree. assertion_truncation_level or truncation_level maybe ?

@Pierre-Sassoulas
Copy link
Contributor Author

I need to take into account #6292, #5285 and #6723 on top of #3962, I'm going to rethink this a little.

@nicoddemus
Copy link
Member

I agree. assertion_truncation_level or truncation_level maybe ?

The second makes sense if we will be using it for other things than just the assert truncation.

@Pierre-Sassoulas Pierre-Sassoulas added the type: enhancement new feature or API change, should be merged into features branch label Apr 2, 2023
Closes pytest-dev#3962

Co-authored-by: Daniel Hahler <github@thequod.de>
@Pierre-Sassoulas
Copy link
Contributor Author

Closing as it was done in #11473

@Pierre-Sassoulas Pierre-Sassoulas self-assigned this Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add distinct option to show full (assertion) diffs always
2 participants