-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-59000: Fix pdb breakpoint resolution for class methods when module not imported #141949
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
Changes from 2 commits
7844490
701050f
7b8fe20
25c8819
df88534
b59d79a
53ac260
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4587,6 +4587,31 @@ def bar(): | |
| ])) | ||
| self.assertIn('break in bar', stdout) | ||
|
|
||
| def test_issue_59000(self): | ||
| script = """ | ||
| def foo(): | ||
| pass | ||
|
|
||
| class C: | ||
| def c_foo(self): | ||
| pass | ||
| def foo(self): | ||
| pass | ||
|
|
||
| foo() | ||
| """ | ||
| commands = """ | ||
| break foo | ||
| break C.foo | ||
| break C.c_foo | ||
| break 10 | ||
| continue | ||
| break C.foo | ||
| quit | ||
| """ | ||
| stdout, stderr = self.run_pdb_script(script, commands) | ||
| self.assertIn("The specified object 'C.c_foo' is not a function", stdout) | ||
|
||
|
|
||
|
|
||
| class ChecklineTests(unittest.TestCase): | ||
| def setUp(self): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix :mod:`pdb` breakpoint resolution for class methods when the module defining the class is not imported. |
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.
You are testing the wrong thing. You should test
C.foo, notC.c_foo. So a good practice is to confirm that your test fails before your fix and passes after. Also from the other PR - do not test what you don't want to. Make the test minimal.C.c_foois not important here. Let's simplify the test.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.
Thank you for taking the time to review. I have made some changes.
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.
You are still testing too much. The purpose of a regression test is to test for the specific thing you fixed. When other developers read this test in the future, they should understand what is the bug back then. It's different than a feature test which needs to be comprehensive.
The only thing in this fix is that the user should not be able to set a breakpoint for
C.fooiffooexists - that's the thing you should test for. All the other stuff are not related. Let's minimize the test case so it tests just this case. And by "minimize", I meant you can't delete anything anymore because every line is useful.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.
Thanks again for your review! I've pared the test cases down to the minimum needed.