bpo-30870: IDLE: Add configdialog fontlist unittest#2666
bpo-30870: IDLE: Add configdialog fontlist unittest#2666terryjreedy merged 12 commits intopython:masterfrom
Conversation
|
@mlouielu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @terryjreedy, @csabella and @kbkaiser to be potential reviewers. |
| self.attach_var_callbacks() # Avoid callbacks during load_configs. | ||
|
|
||
| if not _utest: | ||
| self.grab_set() |
There was a problem hiding this comment.
I believe at least some other dialogs have grab_set here already. Is this move also needed for event_generate?
There was a problem hiding this comment.
I only saw it at textview that control with model argument. grab_set somehow will affect event_generate, too.
There was a problem hiding this comment.
test_textview mock out the grab_set, hmm. Should we mock out, too?
There was a problem hiding this comment.
Since it will not be called, no need. I just read the UNM Shipman doc "Widget w grabs all events for w's application. If there was another grab in force, it goes away. See Section 54, “Events” for a discussion of grabs." Seems to be related to dialog being modal. Did not see anything in Sect.54 though. I need to make sure I know about all the calls in various inits.
terryjreedy
left a comment
There was a problem hiding this comment.
Super. Will look at tests later.
|
Appveyor, running on Windows, and my Win 10 machine, say: FAIL: test_key_up_down_should_change_font_and_sample (idlelib.idle_test.test_configdialog.FontTabTest) |
|
@terryjreedy I think the assertion is correct, the result we want to pass is the |
|
After adding |
|
@mlouielu I initially mis-interpreted Appveyor result before I ran test myself and realized that the failure was correct and pointed to a need for a fix. I presume focus_force created no problem on your Linux. |
|
I have reviewed and am revising and will push for review and test. Please don't push any more commits for now. |
|
Changes:
|
| fontlist = dialog.fontlist | ||
| fontlist.activate(0) | ||
|
|
||
| # Select next item in listbox |
There was a problem hiding this comment.
Need two more space for the comment. I'll fixed this.
|
@terryjreedy Thanks for your help, this makes the test more reliable. I fix some nit point about styling. Otherwise LGTM. |
| fontlist.event_generate('<Button-1>', x=x+dx//2, y=y+dy//2) | ||
| fontlist.event_generate('<ButtonRelease-1>', x=x+dx//2, y=y+dy//2) | ||
| fontlist.event_generate('<Button-1>', x=x + dx // 2, y=y + dy // 2) | ||
| fontlist.event_generate('<ButtonRelease-1>', x=x + dx // 2, y=y + dy // 2) |
There was a problem hiding this comment.
I disagree. For an assignment statement, I would write
x = x + dx//2
Following math tradition here is allowed by pep8. When the space around '=' is deleted, as per PEP8, it looks weird, and visually deceptive, to leave space around '+'. I don't know if this is specifically addressed.
There was a problem hiding this comment.
After re-reading PEP8, I concur with your way to present x = x + dx//2, but it's weird in this situation, too.
I convert it to another way to represent:
x += dx // 2
y += dy // 2
event_generate(x=y, y=y)
I hope this will be more general in this case.
There was a problem hiding this comment.
With two uses, that looks better.
| @classmethod | ||
| def tearDownClass(cls): | ||
| del dialog.set_font_sample # unmask instance method | ||
| del dialog.set_font_sample # Unmask instance method |
There was a problem hiding this comment.
Old habits die hard. I added the '.'s.
|
|
||
| def test_select_font_mouse(self): | ||
| # Click on item should select that item. | ||
| "Click on item should select that item." |
There was a problem hiding this comment.
I tried this once and stopped when I discovered that running a file with unittest.main(verbosity=2) prints the docstrings, as in this example where I added one. Ditto for python -m test.test_idle -v.
test_font (__main__.FontTabTest) ... ok
test_set_sample (__main__.FontTabTest)
Set_font_sample also sets highlight_sample. ... ok
test_tabspace (__main__.FontTabTest) ... ok
I decided I did not like it and reverted the couple of examples.
Verbosity 1 prints a '.' for each successful test. 0 prints nothing until the end.
With the effect understood, I am willing to discuss a change, with at least Cheryl included.
In the meanwhile, please revert (you can use pencil edit upper right).
There was a problem hiding this comment.
OK, revert this first.
…ythonGH-2666) Initial patch by Louie Lu. (cherry picked from commit 9b622fb)
No description provided.