Skip to content

Remove ExceptionInfo.__str__, falling back to __repr__#5413

Merged
nicoddemus merged 1 commit into
pytest-dev:masterfrom
nicoddemus:exc-info-str-5412
Jun 7, 2019
Merged

Remove ExceptionInfo.__str__, falling back to __repr__#5413
nicoddemus merged 1 commit into
pytest-dev:masterfrom
nicoddemus:exc-info-str-5412

Conversation

@nicoddemus

Copy link
Copy Markdown
Member

Fix #5412

@codecov

codecov Bot commented Jun 6, 2019

Copy link
Copy Markdown

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

blueyed commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

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

@nicoddemus

Copy link
Copy Markdown
Member Author

You mean adding this to ExceptionInfo.__repr__?

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

@asottile asottile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@blueyed

blueyed commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

You mean adding this to ExceptionInfo.__repr__?

Yes - or something similar.

@nicoddemus

Copy link
Copy Markdown
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

blueyed commented Jun 7, 2019

Copy link
Copy Markdown
Contributor

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