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

Issue 1316 - longrepr is a string when pytrace=False #7100

Merged
merged 10 commits into from
May 30, 2020

Conversation

CarycaKatarzyna
Copy link
Contributor

This pull request fixes #1316. I've added new _TracebackStyle - no_pytrace. For that style ReprExceptionInfo has as few information as possible. For example report.longrepr.chain is

[(ReprTraceback(reprentries=[ReprEntry(lines=['Hello World'], reprfuncargs=None, reprlocals=None, reprfileloc=None, style='no_pytrace')], extraline=None, style='no_pytrace'), None, None)]

for code contained in issue #1316.

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 @CarycaKatarzyna for tackling this very old issue! 👍

Please take a look at my comments.

changelog/1316.bugfix.rst Outdated Show resolved Hide resolved
testing/test_runner.py Outdated Show resolved Hide resolved
src/_pytest/_code/code.py Outdated Show resolved Hide resolved
@nicoddemus
Copy link
Member

nicoddemus commented May 5, 2020

Rebased to fix linting.

Thanks a lot @CarycaKatarzyna!

@nicoddemus
Copy link
Member

We should squash all commits on merge btw. 👍

Copy link
Member

@bluetech bluetech left a comment

Choose a reason for hiding this comment

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

Great cleanup, that str was really hacky. I left some minor comments but otherwise LGTM.

Also, we should consider adding value as a supported option to --tb - this will satisfy the use case in #6651 (and replace PR #6652). WDYT?

src/_pytest/_code/code.py Outdated Show resolved Hide resolved
src/_pytest/_code/code.py Outdated Show resolved Hide resolved
src/_pytest/junitxml.py Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
``TestReport.longrepr`` is now always an instance of ``ReprExceptionInfo``. Previously it was a ``str`` when a test failed with ``pytest.fail(..., pytrace=False)``.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
``TestReport.longrepr`` is now always an instance of ``ReprExceptionInfo``. Previously it was a ``str`` when a test failed with ``pytest.fail(..., pytrace=False)``.
``TestReport.longrepr`` is now always an instance of ``ReprExceptionInfo``. Previously it was an ``str`` when a test failed with ``pytest.fail(..., pytrace=False)``.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

str starts with 's' which is a consonant. Why do you think that 'an' is a proper spelling?

Copy link
Member

Choose a reason for hiding this comment

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

I read it as ESS-TEE-ARR, but maybe others don't. Not a big deal either way :)

@nicoddemus
Copy link
Member

Also, we should consider adding value as a supported option to --tb - this will satisfy the use case in #6651 (and replace PR #6652). WDYT?

Great idea! We should consider doing that in a separate PR thought.

@bluetech bluetech merged commit 94c7b8b into pytest-dev:master May 30, 2020
@bluetech
Copy link
Member

Thanks @CarycaKatarzyna!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TestReport.longrepr is a string when pytest.fail(..., pytrace=False) is used
4 participants