-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add method to pip test result #7869
Conversation
Hey @pradyunsg ! Can you please have a look at this. :) |
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.
2 broad comments, one for clarity, one for correctness.
tests/functional/test_download.py
Outdated
) | ||
assert script.site_packages / 'piptestpackage' not in result.files_created | ||
result.did_create( | ||
Path('scratch') / 'meta-1.0-py2.py3-none-any.whl') |
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.
nit: for clarity
Path('scratch') / 'meta-1.0-py2.py3-none-any.whl') | |
Path('scratch') / 'meta-1.0-py2.py3-none-any.whl' | |
) |
result.did_create(egg_info), \ | ||
"Couldn't find {egg_info}".format(**locals()) |
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.
Hmm, looks like here (and a lot more places) the assertion didn't get translated well.
assert x in Y, message
Got changed to:
result.did_create(x), message
Which isn't right. For now, I suggest undoing the changes in those locations. We'll come back to them in a follow up PR. :)
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.
result.did_create(x), message
wouldn't work, right -- Either message needs to be passed as a parameter, or a better option IMHO would be to let result.did_create
return a boolean, and assert the correctness in the test function itself. This would also improve it's readability:
assert result.did_create(x), message
@pradyunsg would love to hear what you think on this.
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.
I also support the way @RJ722 suggested. That does seem straightforward. :)
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.
The thing is, we'd want to always have the message include str(result)
, since it contains useful debugging information. Part of the point of making this change, is to get rid of needing to specify the message every time.
I think we'd likely want to add a message keyword-only argument to result, so that we can add to the default error message:
result.did_create(X, message=message)
That should do:
assert X in self.created, "\n".join(message, str(self))
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.
There's a whole bunch more left (I didn't actually scroll all the way to the end of this PR).
Thanks for the quick review @pradyunsg ! I got a bit confused with this change, but seems now I understood. I will update the PR. :) |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
Hi @ssurbhi560 , Looks like the changes made in this PR are passing CI checks. Once you resolve the merge conflict, I believe this PR will be in a reviewable state again. |
972438d
to
962f46f
Compare
tests/lib/__init__.py
Outdated
if message is None: | ||
message = str(self) | ||
else: | ||
message = "\n".join((message, str(self))) |
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.
I see that this if-else
is being repeated at 4 places. Maybe it's a good idea to move this in it's own function, and use a single line if-else. (Or you can just move it in your own function, and not use the single line if-else for readability)
def create_msg(message=None):
return "\n".join((message, str(self))) if message else str(self)
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.
Sorry for bikeshedding, but I think it's more readable to have the messaged string as {}\n{},format(message, self)
. A bit more importantly, the repetition signals that the assertions are similar enough that parameterizing them might be a good idea.
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.
Sorry for bikeshedding, but I think it's more readable to have the messaged string as {}\n{},format(message, self)
Agreed that return '{}\n{}'.format(message, self) if message else self
is a better idea (We don't need to explicitly cast self
to str
via str(self)
A bit more importantly, the repetition signals that the assertions are similar enough that parameterizing them might be a good idea.
I think it was suggested at #6050 (comment) to have different functions for asserting in
and not in
of self.files_created
and self.files_updated
962f46f
to
7a2c2d6
Compare
@ssurbhi560, I am glad you're back. I was actually working over this PR to resolve the conflict(glad that you've already resolved it) and break it into smaller PRs.
Let me know if you are going to keep working over it else I would take over the work. :) |
@gutsytechster, I'd be glad to continue working on this, sorry for the delay that happened this time. |
What @gutsytechster says makes sense to me! :) In terms of breaking this down, I think the first PR (adding the methods) is likely the only bit that has to be only-one-person-does-it. The follow up PRs can be independent, and done by different folks, as long as there's some sort of conflict avoidance (eg: one person does all "install" test files, another doing everything else). |
Hello! I am an automated bot and I have noticed that this pull request is not currently able to be merged. If you are able to either merge the |
To that end, I've gone ahead and filed #8303 for this. That should unblock us and allow us to incrementally move over all of pip's tests to using the helpers introduced in that PR.
If @ssurbhi560 and @gutsytechster are tackling these, I suggest using the split suggested above. Keep the PRs small, at most two files per PR, and tackle away at this! :) |
Now that we have a plan in place on how to break this PR into smaller PRs, I think we can close this PR. |
Towards #6050