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
IDLE: add tests for help_about.py #74476
Comments
Initial plan. Separate issue: add simulated button click tests to test_textview and other popup dialogs. Directly calling commands does not test that buttons invoke the right command. |
4a. Change uglyMidcap widget names and CamelCase function names to pep8_conformant names. Simplify: byline, email, docs, pyver, tkver, idlever, py_license, py_copyright, py_credits, readme, idle_news, idle_credits. 4b. Change CamelCase function names to pep8_conformant names.
bpo-30303 implemented 2a, improve textview and tests. Cheryl: this should be much easier than colorizer. Let me know if you want to take a stab at at least 4 and 5. |
Follow-up issues. A. Move code and tests into help.py and test_help.py. |
This looks like fun! :-) I'll let you know if I have any questions. |
Terry, Is there interest in changing the 'from tkinter import *'? |
I take 'fun' to mean you will try something. And yes, I have thought about the following for all IDLE modules.
6a requires more typing in the import statement, but as a replacement, leaves the rest of the code alone. It documents what widgets will be used in the module. It allows individual classes to be mocked for a particular test or group of tests. I know I have done this for the tkinter TypeVar classes. 6b has a short import but requires more typing in the module body, especially when tkinter constants are present, as they are here. When exploring or writing short, one-off programs, I usually use 'as tk'. But for IDLE, I may have converted at least one file to 'as tk', but I am now using 'import Tk, ...' and prefer it. My current thoughts about Tkinter constants versus string literals, such as BOTH versus 'both': The two forms by themselves are about equally easy to type. The CAPS form is shorter but louder, whereas to me they are minor items that should not be loud. The constants seem designed to work with 'import *'; one can then potentially use name completion for the longer names. After 'as tk', I think "tk.Both" is worse than "'both'". For new code with explicit imports, adding constants to the imports is extra work. For existing code with many constants, such as help_about, adding constants to the imports is less work than converting. So I am inclined to leave them as are until such time as we might do a search-replace throughout idlelib. When there are a few constants, I have put them after the classes. For this module, I would like to try a separate import rather than use '\' line continuation. from tkinter import TOP, BOTTOM, SIDE, SUNKEN, EW, ... In one file with just two constants, I initially converted to the quoted literal, but another core dev objected on the basis that the constants are checked when the function is compiled instead of when called, and that this is somehow safer. For when issue comes up again, I am recording my current replies here.
|
Louie, at first glance, this appears to implement the remaining changes in 1 and 2. A possible problem is that I expect the needed 'self.' additions will conflict with the name changes on the same lines that Cheryl said she would do, about 10 hours ago. Cheryl, if you have not yet started your patch, hold off for now, until I can properly review Louie's patch. |
Oh, I had started to make the changes, but that's OK. I'm still doing discovery too. 'Fun' did mean that I'll try something. This is exactly what I wanted to work on to dive into tkinter and idle, so I got excited. Louie, just to coordinate, are you working on other items that Terry listed here? Terry, should I do each item in its own PR for quick review or should I try to do many at once in a single PR? I was doing both the name changes and docstrings (and now maybe the import change) in one PR, but maybe that's too much? |
Cheryl: yes, I may work on 4a/4b and msg294004 on Monday, or do you start at these tasks? |
I am about to go to bed, way late. I would like to review and apply all the non-test changes, 4,5,6 in one PR, and add 3 since I know what I meant. There can be multiple commits in one PR though. Louie, from bpo-30422 and a tracker search, you can see that there is lots to do, for more that 1 or even 2 people. I think 4,5,6 are a good way for Cheryl to start with IDLE. Other files need similar changes that do not need your tkinter skills. If you are looking for a useful challenge, there are 12 open IDLE debugger issues + some enhancements debugger ideas I have not bothered to post yet. If that does not interest you, I can try to suggest something else after I get up again. I expect to be away from my computer on my Monday. |
PR merged. I will worry about where in the test to call AboutDialog.Ok, which has the last uncovered line - and any other details -- later, perhaps when I merge this file into help.py. |
Terry: I see, I'll take some debugger stuff to try first. |
I've made a pull request for 4, 5, and 6. I didn't remove the tk constants as it seemed you'd like to do all the files in one project for that. Also, in query.Query, I noticed that all the widgets were created first and then they were all added to the grid last. I didn't move any existing lines for this, but can do that if it's preferred. It also seemed like helper functions might make it more readable (create_py_section, create_idle_section), but maybe that's too much churn compared to what this will end up looking like. |
At first glance, 1714 looks great. I hope to merge it tomorrow. On the issues you raised:
However, a alternate design could have links with standard blue tagging instead of buttons. For example, the current About Firefox box has these 8 links: 'What's new', 'Mozilla', 'a global community', 'Make a donation', 'get involved', 'Licensing Information, 'End-User Rights', and 'Privacy Policy'. This would make code much shorter and the result would not have the issues above. |
Thanks Terry. I'll leave those other items alone for now. It makes sense what you said about the 'create widget' styles. Looking at it for the first time, I kind of liked the second version (in query) because I could more immediately understand what was happening, plus it seemed to lend itself to modularizing. For example, have one function that has all 'create' and one that has all the 'place'. help_about was a small dialog and there were already a lot of lines of code. But, to your last point, blue tagging seems like it would make it all easier. For the next step, do you have a plan in mind for what you'd like me to do next? I know you mentioned ttk for help_about, but didn't know if you wanted me to tackle that. Or should I PEP-8 and docstring other modules such as textview.py and configdialog.py? One question I forgot to ask before -- the |
While reviewing, I decided to draw a widget tree. I believe it would have been easier if packs and grids were grouped. I want to continue with 'IDLE: modernize help-about' and ditto for textview. The help_about issue can begin with ttk conversion: change imports and remove an invalid option or two. The textview issue can begin with the still missing docstrings. I want to refactor both the way I discussed in the roadmap issue: make separate Toplevel and Frame subclasses. The Toplevel subclass instance creates a Frame subclass instance which becomes an attribute of the toplevel. Help.py already has this structure. |
Thanks Terry. I've submitted a PR for the textview docstrings and PEP-8 names and I'll work on the ttk conversion and the refactoring. |
A follow-up to my brief remarks about revamping About IDLE, in msg294298: idle-dev is subscription-required public forum for discussion of idle design issues. It has been dormant for a year and a half, but I would like to revive it to get broader user input. By coincidence, the first new post (held since April because the author is not subscribed) is a suggestion for AboutIDLE. In my second response, I listed 9 possible or definite changes. I would like that to be where we plan a future 'Modernize About IDLE' issue. |
Postscript: this test that the retrieved text has at least two lines caught a bug in the new Windows Store python distribution. self.assertEqual(printer._Printer__lines[1],
dialog._current_textview.textView.get('2.0', '2.end')) The license file was missing and the backup default had only one line. |
The following PRs were merged:
Are there more work to be done here? If not, this could be closed. |
This became a meta-issue, which was awkward on bpo because of not being able to edit the todo list and add completion checkmarks and the issue in-place. I need to review this and other IDLE tracking/meta-issues and replace with up-to-date GH task lists. (Link is for me.) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: