bpo-30981: IDLE: Add more configdialog font page tests. by csabella · Pull Request #2805 · python/cpython (original) (raw)

Thank you again for explaining that. I"m trying so hard to understand the reasons for doing certain unit tests in certain ways and I still don't have a good grasp of things, like when to delete variables or even what to test. :-(

I had mocked out font_bold because of the side effect of the trace causing the font_bold changes to be added to changes and thus affecting the result of test_font_set. Currently, if test_set_samples_bold_toggle runs before test_font_set, then test_font_set fails. It appears that the test methods run alphabetically. Is that how you make sure they will run in the correct order?

This is what I get in test_font_set if it's not run first:

======================================================================

FAIL: test_font_set (main.FontTabTest)

Traceback (most recent call last):
File "Lib/idlelib/idle_test/test_configdialog.py", line 66, in test_font_set
self.assertEqual(mainpage, expected)
AssertionError: {'EditorWindow': {'font': 'Test Font', 'font-size': '5', 'font-bold': 'True'}} != {'EditorWindow': {'font': 'Test Font', 'font-size': '10', 'font-bold': 'False'}}

Because changes records the .set() and invoke() calls in test_set_samples_bold_toggle, mainpage no longer matches GetFont in test_font_set.


Additional Info:
Realized that changes.clear() should be clearing the changes and thus one test shouldn't affect another. The issue is that var_changed_font sets the value of changes on all three font variables and it has font_size and font_bold as carryover from test_set_samples_bold_toggle. So, if the tests are run out of order, changes doesn't match GetFont because of the dialog.font_name.set() in test_font_set. Is this a testing issue where font_size and font_bold need to be initialized in test_font_set? Or is it an issue with clearing changes that the actual Tk variables aren't changed back to some default when changes is cleared?