[issue18279] IDLE Unit test for RstripExtension.py

Terry J. Reedy report at bugs.python.org
Fri Jul 5 04:28:17 CEST 2013


Terry J. Reedy added the comment:

I want to make two separate commits. First add mock Text into mock_tk.py, and add a new test_text.py. I suggested looking at the tkinter Text test. I turns out that it only tests a few special search cases. I am guessing that they have something to do with the tkinter interface. If neither you nor Todd feel like writing the Text test, I will. Let me know either way.

Second, add the new mock_idle and test_rstrip files. For the latter, at least one line should have no whitespace, and one should have an indent. With an indent, the test would fail if rstrip in the tested file were changed to strip.

In the tearDown method, the apparent purpose of
        self.rstripextension = None
is to actually do
        del self.rstripextension
and that happens automatically when self disappears.
With a mock editor window, there is no need for "root.destroy" and hence for the close call, and hence for the tearDown method.

With only one test method, the setUp lines can be part of the test. For the attribute names, I strongly prefer 'rstrip' to 'rstripExtension' and 'editor' to 'mockEditorWindow'.

I am curious about this comment:
# Note: Tkinter always adds a newline at the end of the text widget,
# hence the newline in the expected_text string

In live Idle, I tried 'strip trailing whitespace' with text that did not end with \n and there was none visible after.

An annoyance is that after stripping  the filename is prefixed with * to indicate that it has been changed and needs to be changed, even when it has not (or should not have been). Closing brings up the unnecessary 'Changed, save?' box. Is this related to the comment?

----------
stage:  -> patch review

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18279>
_______________________________________


More information about the Python-bugs-list mailing list