-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
A few tiny micro-optimizations/simplifications #7238
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
Conversation
`write_fspath_result` already does this split.
This is already done in pytest_runtest_logstart, so the fspath is already guaranteed to have been printed (for xdist, it is disabled anyway). write_fspath_result is mildly expensive so it is worth avoiding calling it twice.
@@ -474,10 +473,7 @@ def pytest_runtest_logreport(self, report: TestReport) -> None: | |||
else: | |||
markup = {} | |||
if self.verbosity <= 0: | |||
if not running_xdist and self.showfspath: | |||
self.write_fspath_result(rep.nodeid, letter, **markup) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is never reached?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is reached, but has the same outcome as just the write
.
What write_fspath_result
does is check whether the path (extracted from the nodeid) is different than the last call to write_fspath_result
, and if so, starts a new line and prints the path, before printing the argument.
The reason it's not needed here is that pytest_runtest_logstart
already calls write_fspath_result
, so the call here (logreport
) doesn't.
Because the check it performs is mildly expensive, it's good to avoid it when possible.
@@ -443,8 +443,7 @@ def pytest_runtest_logstart(self, nodeid, location): | |||
self.write_ensure_prefix(line, "") | |||
self.flush() | |||
elif self.showfspath: | |||
fsid = nodeid.split("::")[0] | |||
self.write_fspath_result(fsid, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now different, correct? Or does is it have the same outcome?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write_fspath_result
does this:
fspath = self.config.rootdir.join(nodeid.split("::")[0])
(and doesn't use nodeid
otherwise) so the split is redundant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for the clarifications!
No description provided.