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-79871: IDLE - Fix and test debugger module #11451
base: main
Are you sure you want to change the base?
Conversation
… using the modern super function
…andling of frames in user_line
|
Also requesting review from @csabella |
|
I'm going to continue merging tests into this PR instead of opening separate ones |
…the '.reset()' method. This method is never called, so the attribute does not exist and under certain situations, could crash the debugger window
|
just realised I've been writing these all as pytest assertions. Will amend existing commits |
|
@terryjreedy I'm still adding tests so this isn't ready for review yet. But early feedback would be welcome as this is my first foray into the idle_test suite |
|
Yes, additional debugger tests should go here. |
|
@terryjreedy I've finished the test suite. There is quite a heavy use of mock, but mostly to isolate the behaviours and validate that the methods call the underlying components with the correct values. I've also created a class in here as a reflection of Something I saw a lot but wasn't sure why it existed, where these empty single-line comments. https://github.com/python/cpython/pull/11451/files#diff-6428b52d9491cd87d1aaac56558bdd7bL235 do you know what they're for? I assumed to break up the large functions, but empty lines are normally used for that. I've never come across it before and wondered if there was a reason. |
|
Which commands were you using to run the tests? From this branch, I'm running PYTHON_PATH=Lib ./python.exe -m idlelib.idle_test.test_debuggerI ran |
|
The 0df2512 changeset introduces an issue where the stack viewer window stays open when the tests are run. This is causing the crash on CI |
I'm not in any rush, I want to get this right. It'll take me a bit of time to understand the feedback too as I'm unfamiliar with the process and the library |
|
For running all the IDLE tests, you can just try One thing that I've found helpful (on both Linux and Windows) is to create a venv. On Windows (your command shows .\python.exe, so I think you're using Windows), there is a command
Yeah, every project is a little different, so that's why I wanted to give you a heads up. :-) |
I'm not sure if teardowns will fix this or not, but they might. So, for now, I'll wait to look at the test errors and failures until then. On my machine, I'm getting these results when running the tests. Since they worked before, my first thought is that the difference would be related to changing where the objects are created, so that is what needs to be tracked down. |
|
I run tests either from an editor window or in the console in the top repository directory. The repository has python.bat for Windows, so '3x> python -m test.test_idle' runs the tests with the latest repository build. I re-downloaded and re-ran test_debugger both by itself and with the idle suite. The previous errors are gone. The debug controls stack up until the test pauses. It finished after I closed some. There should be only one open at a time. I get the same 2 'invalid command name' errors, but not the load_stack error. Coverage is 75% for me. I am puzzled why the configure call fails. When I commented out |
|
I should have mentioned before that I want opening comments (when appropriate) instead of docstrings for test_xyz methods. Both are equally visible to readers, but docstrings are added to the output in -v mode, which to me is a nuisance. I intend to change them, though not at the moment. |
|
I wondered if the fact that debug window still uses tk widgets inside a ttk Frame could be an issue (we must finish this). But I don't see any problem when using the debugger, and I am pretty sure that iteract() is being called. |
|
I figured out why it hangs, the |
… a user interaction, which makes the tests hand
… (because a single frame would never exist)
…mpact the exact coverage number
…d an Idb instance and those which don't
|
@csabella @terryjreedy sorry for the delay, I've refactored the code based on your comments and feedback and fixed the hanging test issues |
|
No problem. We have both been busy with other issues. I will look at this after doing more on tests for another IDLE module. |
|
@terryjreedy @csabella please could you take another look at this PR for targeting 3.9? |
|
Is the PR still relevant? |
|
Probably. I plan to review all idlelib issues this summer. |
This pull request adds tests for the (currently untested)
idlelib.debugger.Idbclass.These tests are unit tests to validate the existing behaviours.
2 behaviours have been changed:
Idbto callsuper(the Python 2/3 style) instead of calling__init__directly. This won't have execution, but I think this code was written well before super existed. 17 years ago according to blame..in_rpc_codeguards against the previous frame being None. Since this method recursively checksf_backwhen the file matches certain conditions, if it eventually hits the first frame,f_backwould be None.