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

Fix TestReport.longreprtext when TestReport.longrepr is not a string #7561

Merged
merged 1 commit into from Jul 29, 2020

Conversation

nicoddemus
Copy link
Member

Fix #7559

@@ -82,9 +82,10 @@ def toterminal(self, out: TerminalWriter) -> None:
longrepr.toterminal(out)
else:
try:
out.line(longrepr)
Copy link
Member Author

Choose a reason for hiding this comment

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

@bluetech do you know why mypy didn't catch this problem? TerminalWriter.line expects a str argument, but longrepr is declared as Any in the class definition.

Copy link
Member

Choose a reason for hiding this comment

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

a function which accepts str also accepts Any because it's gradually typed (there's options to turn this off in mypy, but getting to that ideal is very very difficult)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh I indeed:

Any

A static type checker will treat every type as being compatible with Any and Any as being compatible with every type.

Thanks! My thought was that a function declaring str would accuse Any as incompatible, but the above definition clearly states otherwise. 👍

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.

@@ -82,9 +82,10 @@ def toterminal(self, out: TerminalWriter) -> None:
longrepr.toterminal(out)
else:
try:
out.line(longrepr)
Copy link
Member

Choose a reason for hiding this comment

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

a function which accepts str also accepts Any because it's gradually typed (there's options to turn this off in mypy, but getting to that ideal is very very difficult)

apevec pushed a commit to redhat-openstack/rdoinfo that referenced this pull request Jul 29, 2020
pytest 6.0.0 has broken the job with issue [1],
until it's fixed with PR [2] and released let's pin it.

[1] pytest-dev/pytest#7559
[2] pytest-dev/pytest#7561

Change-Id: I073cfbcb4a65e716373f0a4df4766fd38a801618
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.

LGTM. I think CollectErrorRepr might need the same treatment, not sure.

The typing of longrepr is unfortunate...

@ssbarnea
Copy link
Member

Anyone with merge and release super powers? That changes deserves a fast track. I already opened pytest-dev/pytest-html#318 as I have a strong interest in keeping this plugin green and compatible with any new release of pytest.

@nicoddemus
Copy link
Member Author

Anyone with merge and release super powers?

Every maintainer has that. 😁

We should have a release real soon, as there are a number of regressions we should take care. 👍

@nicoddemus
Copy link
Member Author

LGTM. I think CollectErrorRepr might need the same treatment, not sure.

Good call! It didn't require changes, but I added a test to avoid future regressions.

The typing of longrepr is unfortunate...

Indeed. We should eventually try to narrow down all possible values it might have, to eventually refactor that out somehow.

@nicoddemus nicoddemus added the needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch label Jul 29, 2020
@nicoddemus nicoddemus merged commit 095bf19 into pytest-dev:master Jul 29, 2020
@nicoddemus nicoddemus deleted the longreprtext-7559 branch July 29, 2020 12:47
nicoddemus added a commit to nicoddemus/pytest that referenced this pull request Jul 29, 2020
nicoddemus added a commit that referenced this pull request Jul 29, 2020
[6.0.x] Merge pull request #7561 from nicoddemus/longreprtext-7559
@nicoddemus nicoddemus added backported PR has been backported to the current bug-fix branch and removed needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch labels Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported PR has been backported to the current bug-fix branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

INTERNALERROR when skipping a test if using --html=report.html (pytest 6.0.0)
4 participants