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

Remove ExceptionInfo.__str__, falling back to __repr__ #5413

Merged
merged 1 commit into from Jun 7, 2019

Conversation

nicoddemus
Copy link
Member

Fix #5412

@codecov
Copy link

codecov bot commented Jun 6, 2019

Codecov Report

Merging #5413 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5413      +/-   ##
==========================================
- Coverage   95.98%   95.98%   -0.01%     
==========================================
  Files         114      114              
  Lines       25523    25511      -12     
  Branches     2480     2479       -1     
==========================================
- Hits        24499    24487      -12     
  Misses        718      718              
  Partials      306      306
Impacted Files Coverage Δ
src/_pytest/_code/code.py 94.32% <ø> (-0.06%) ⬇️
testing/code/test_excinfo.py 96.55% <100%> (-0.03%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 450d264...65c2a81. Read the comment docs.

@blueyed
Copy link
Contributor

blueyed commented Jun 6, 2019

I think having the location there is useful in general, but should come via ExceptionInfo then instead - if wanted.

@nicoddemus
Copy link
Member Author

You mean adding this to ExceptionInfo.__repr__?

entry = self.traceback[-1]
loc = ReprFileLocation(entry.path, entry.lineno + 1, self.exconly())

Copy link
Member

@asottile asottile left a comment

Choose a reason for hiding this comment

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

@blueyed
Copy link
Contributor

blueyed commented Jun 6, 2019

You mean adding this to ExceptionInfo.__repr__?

Yes - or something similar.

@nicoddemus
Copy link
Member Author

Adding the location gives this:

<ExceptionInfo ValueError tblen=2 location=C:\Users\bruno\pytest\testing\code\test_excinfo.py:338: ValueError: an error value>

Isn't that a too long?

@blueyed
Copy link
Contributor

blueyed commented Jun 7, 2019

Isn't that a too long?

Maybe, yes. But you have the exception type there twice.
I think it is fine for now as of this PR.

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.

str() on the pytest.raises context variable doesn't behave same as normal exception catch
3 participants