bpo-30303: IDLE: Add _utest argument to textview#1499
bpo-30303: IDLE: Add _utest argument to textview#1499terryjreedy merged 8 commits intopython:masterfrom louisom:bpo-30303
Conversation
terryjreedy
left a comment
There was a problem hiding this comment.
At first reading, the textview.py changes are just right. The test needs some minor changes.
| def _command(): | ||
| self.called = True | ||
| self.view = tv.view_text(self.root, 'TITLE_TEXT', 'COMMAND', _utest=self._utest) | ||
| button = Button(self.root, text='BUTTON', command=_command) |
There was a problem hiding this comment.
Use global 'root' here and below.
|
|
||
| class ButtonClickTextViewTest(unittest.TestCase): | ||
| @classmethod | ||
| def setUpClass(cls): |
There was a problem hiding this comment.
I don't think this and tearDownClass are needed. The module root should work. Just pass '_utest=True' in both calls.
| ''' | ||
| from idlelib import textview as tv | ||
| from test.support import requires | ||
| from test.support import requires, findfile |
There was a problem hiding this comment.
See comment below about findfile.
| @@ -8,12 +8,12 @@ | |||
| Coverage: 94%. | |||
There was a problem hiding this comment.
After I adapt my coverage.bat to work with the git repository, I will get new value.
|
|
||
| self.assertEqual(self.called, True) | ||
| self.assertEqual(self.view.title(), 'TITLE_TEXT') | ||
| self.assertEqual(self.view.textView.get('1.0', '1.end'), 'COMMAND') |
There was a problem hiding this comment.
Follow with 'button.destroy()'.
There was a problem hiding this comment.
I'm using addCleanup instead of directly using button.destroy
|
|
||
| def test_view_file_bind_with_button(self): | ||
| def _command(): | ||
| fn = findfile('CREDITS.txt', 'idlelib') |
There was a problem hiding this comment.
osp = os.path
fn =osp.abspath(osp.join(osp.dirname('file'), '..', 'CREDITS.txt'))
would be equivalent. But to make the test simpler, just pass 'file' instead of fn and adjust assert.
There was a problem hiding this comment.
The boldface __file__is the dunder name interpreted as markup. Unlike StackOverflow, there is no preview of the rendering. Let's try it with backticks __file__.
There was a problem hiding this comment.
Maybe the interpretation is only in quotes? 'file', "file".
There was a problem hiding this comment.
I can't reproduce the equivalent between osp and findfile. On my situation, I'm running unittest at python/cpython, so the osp.dirname('file') will return ``, not Lib/idlelib/idle_test.
There was a problem hiding this comment.
Now with quotes and backticks: backtick inner: "__file__", outer '__file__'.
PS I checked the markdown link below but it was insufficient.
There was a problem hiding this comment.
ah, I see, is __file__, not 'file'
| self.assertEqual(self.view.title(), 'TITLE_FILE') | ||
| self.assertEqual(self.view.textView.get('1.0', '1.end'), | ||
| 'Guido van Rossum, as well as being the creator of the ' | ||
| 'Python language, is the') |
There was a problem hiding this comment.
Using file makes this file self-contained.
self.assertIn(self.view.textView.get('1.0', '1.end'), 'idlelib.textview'
If this file is edited to make this fail, then this file fails immediately.
Codecov Report
@@ Coverage Diff @@
## master #1499 +/- ##
==========================================
- Coverage 83.44% 82.68% -0.76%
==========================================
Files 1368 1432 +64
Lines 346621 353062 +6441
==========================================
+ Hits 289241 291934 +2693
- Misses 57380 61128 +3748
Continue to review full report at Codecov.
|
terryjreedy
left a comment
There was a problem hiding this comment.
I am about to push my changes back and will merge once CI allows.
| self.assertEqual(self.view.textView.get('1.0', '1.end'), | ||
| f.readline().strip()) | ||
| self.assertEqual(self.view.textView.get('2.0', '2.end'), | ||
| f.readline().strip()) |
There was a problem hiding this comment.
I like making this future proof. However, since the 2nd line is blank and Texts have a default extra \n at the end, I believe this would pass even if the textview only displayed one line. So I added an intermediate f.readline() and changed 2s to 3s.
(cherry picked from commit ba365da)
|
Can I ask if a CLA was eventually verified as being signed before merging this? |
|
@brettcannon I asked the PR author in bpo-30303 about this. |
|
@louisom is my previous account, does b.p.o. support comma split (louisom, mlouielu) at the detail page? |
|
🐍🍒⛏🤖 Thanks @louisom for the PR, and @terryjreedy for merging it 🌮🎉.I'm working now to backport this PR to: 3.6. |
|
Sorry, @louisom and @terryjreedy, I could not cleanly backport this to |
|
The backport error is because this was backported already in #1916. (And the file has been refactored since.) I removed the label. |
No description provided.