-
-
Notifications
You must be signed in to change notification settings - Fork 31.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
gh-57879: Increase test coverage for pstats.py #111447
Conversation
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
Maybe @barneygale will be more expert in this area. Would you like to take a look? |
@barneygale @corona10 would you like to help review the PR? |
I will try to take a look until next week. |
@gaogaotiantian Would you like to take a look? |
Do you have the coverage report before and after? It seems like this tries to test a bunch of non-documented helper functions, which is something I'm a bit hesitated to do. They should be (mostly) covered by the existing test of test_profile (I hope). |
true ... seems the coverage is the same Coverage report (lines and percentages) With PR:
Without PR:
|
here is the result... seems no difference ...
|
1% is change :) Like I said, the number on the first column is the total valid line number of the source file - which won't change. The percentage is the covered ratio, and it did change, so this PR increased some coverage, which is good. However, I don't like the way it directly tries to cover some code by calling internal functions. Let's remove So, remove those two classes, the changes for dump and load can stay as they are public APIs. After that, I think it's ready to go. BTW, to view the detailed coverage status, use |
@gaogaotiantian after the change, actually, we just increased the coverage a little bit 😅 coverage change: before/after
|
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
@gaogaotiantian tested. should be fine. |
Still did not fix the file create issue. If you want to create a temporary file without context and temp_storage_new = tempfile.NamedTemporaryFile(delete=False)
try:
self.stats.dump_stats(filename=temp_storage_new.name)
tmp_stats = pstats.Stats(temp_storage_new.name)
# some other code
finally:
temp_storage_new.close()
os.remove(temp_storage_new.name) If you do something like this: temp_storage_new = tempfile.NamedTemporaryFile(delete=False)
self.stats.dump_stats(filename=temp_storage_new.name)
try:
tmp_stats = pstats.Stats(temp_storage_new.name)
# some other code
finally:
temp_storage_new.close()
os.remove(temp_storage_new.name) Then if So could you change that in your test? Thanks. |
@gaogaotiantian sorry I didn't understand correctly. I fixed the |
Hi @corona10 , I think the PR is ready to go. Could you take another look? Thanks! |
Oh and @tigercosmos you need to sign the CLA. Please check the reply from the bot (it's the first reply in this PR). |
I will take a look in 1-2 days. |
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.
lgtm
thank you very much @gaogaotiantian @corona10 |
Original issue: #57879
This work is based on the previous work by @furkanonder on #103928
Mainly fixed comments in the previous PR
@corona10 could you help review?