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

Add method to pip test result #7869

Closed
wants to merge 14 commits into from

Conversation

ssurbhi560
Copy link
Contributor

Towards #6050

@ssurbhi560
Copy link
Contributor Author

Hey @pradyunsg ! Can you please have a look at this. :)

Copy link
Member

@pradyunsg pradyunsg left a 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.

)
assert script.site_packages / 'piptestpackage' not in result.files_created
result.did_create(
Path('scratch') / 'meta-1.0-py2.py3-none-any.whl')
Copy link
Member

Choose a reason for hiding this comment

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

nit: for clarity

Suggested change
Path('scratch') / 'meta-1.0-py2.py3-none-any.whl')
Path('scratch') / 'meta-1.0-py2.py3-none-any.whl'
)

Comment on lines 35 to 36
result.did_create(egg_info), \
"Couldn't find {egg_info}".format(**locals())
Copy link
Member

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. :)

Copy link

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.

Copy link
Contributor

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. :)

Copy link
Member

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))

Copy link
Member

@pradyunsg pradyunsg left a 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).

tests/lib/__init__.py Outdated Show resolved Hide resolved
tests/functional/test_install.py Outdated Show resolved Hide resolved
tests/functional/test_install.py Outdated Show resolved Hide resolved
tests/functional/test_install.py Outdated Show resolved Hide resolved
tests/functional/test_install.py Outdated Show resolved Hide resolved
tests/functional/test_wheel.py Outdated Show resolved Hide resolved
tests/functional/test_wheel.py Outdated Show resolved Hide resolved
tests/functional/test_wheel.py Outdated Show resolved Hide resolved
tests/functional/test_wheel.py Outdated Show resolved Hide resolved
tests/functional/test_wheel.py Outdated Show resolved Hide resolved
@ssurbhi560
Copy link
Contributor Author

Thanks for the quick review @pradyunsg ! I got a bit confused with this change, but seems now I understood. I will update the PR. :)

@BrownTruck
Copy link
Contributor

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 master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label Apr 14, 2020
@deveshks
Copy link
Contributor

deveshks commented May 5, 2020

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.

@ssurbhi560 ssurbhi560 force-pushed the Add_method_to_PipTestResult branch from 972438d to 962f46f Compare May 6, 2020 11:39
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label May 6, 2020
if message is None:
message = str(self)
else:
message = "\n".join((message, str(self)))
Copy link
Contributor

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)

Copy link
Contributor

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.

Copy link
Contributor

@deveshks deveshks May 6, 2020

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

@pradyunsg pradyunsg added the needs rebase or merge PR has conflicts with current master label May 19, 2020
@ssurbhi560 ssurbhi560 force-pushed the Add_method_to_PipTestResult branch from 962f46f to 7a2c2d6 Compare May 20, 2020 12:21
@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label May 20, 2020
@gutsytechster
Copy link
Contributor

gutsytechster commented May 20, 2020

@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.
PR can be broke down in 2-3 PRs with

  • One of them could only add the test methods like assert_did_create etc.
  • Other PRs may update the test files in batches(keeping 2-3 file per PR) so that single PR doesn't become overwhelming with changes.

Let me know if you are going to keep working over it else I would take over the work. :)

@deveshks deveshks mentioned this pull request May 20, 2020
@ssurbhi560
Copy link
Contributor Author

@gutsytechster, I'd be glad to continue working on this, sorry for the delay that happened this time.
About having a lot of changes in one PR is difficult to review, I agree with you on that. Let's just ask what @pradyunsg has to say over this! :-)

@pradyunsg
Copy link
Member

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).

@BrownTruck
Copy link
Contributor

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 master branch into this pull request or rebase this pull request against master then it will be eligible for code review and hopefully merging!

@BrownTruck BrownTruck added the needs rebase or merge PR has conflicts with current master label May 22, 2020
@pradyunsg
Copy link
Member

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.

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.

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).

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! :)

@deveshks
Copy link
Contributor

deveshks commented May 22, 2020

Now that we have a plan in place on how to break this PR into smaller PRs, I think we can close this PR.

@ssurbhi560 ssurbhi560 closed this May 22, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs rebase or merge PR has conflicts with current master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants