Skip to content
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

bpo-30303: IDLE: Add _utest argument to textview #1499

Merged
merged 8 commits into from
May 17, 2017
Merged

bpo-30303: IDLE: Add _utest argument to textview #1499

merged 8 commits into from
May 17, 2017

Conversation

louisom
Copy link
Contributor

@louisom louisom commented May 8, 2017

No description provided.

@louisom louisom changed the title bpo-30303: Add _utest argument to textview bpo-30303: IDLE: Add _utest argument to textview May 10, 2017
Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use global 'root' here and below.

@@ -96,5 +96,52 @@ def test_view_file(self):
self.assertIsNone(view)


class ButtonClickTextViewTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this and tearDownClass are needed. The module root should work. Just pass '_utest=True' in both calls.

@@ -8,12 +8,12 @@
Coverage: 94%.
'''
from idlelib import textview as tv
from test.support import requires
from test.support import requires, findfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment below about findfile.

@@ -8,12 +8,12 @@
Coverage: 94%.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow with 'button.destroy()'.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using addCleanup instead of directly using button.destroy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.


def test_view_file_bind_with_button(self):
def _command():
fn = findfile('CREDITS.txt', 'idlelib')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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__.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the interpretation is only in quotes? 'file', "file".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now with quotes and backticks: backtick inner: "__file__", outer '__file__'.
PS I checked the markdown link below but it was insufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

codecov bot commented May 17, 2017

Codecov Report

Merging #1499 into master will decrease coverage by 0.75%.
The diff coverage is 10.52%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
Lib/idlelib/idle_test/test_textview.py 3.12% <0%> (-1.43%) ⬇️
Lib/idlelib/textview.py 25.45% <57.14%> (-0.48%) ⬇️
Lib/__future__.py 6.45% <0%> (-90.33%) ⬇️
Lib/test/test_select.py 87.69% <0%> (-1.54%) ⬇️
Lib/wsgiref/handlers.py 88.41% <0%> (-0.86%) ⬇️
Lib/test/libregrtest/main.py 59.18% <0%> (-0.35%) ⬇️
Lib/_strptime.py 94.68% <0%> (-0.34%) ⬇️
Lib/bdb.py 26.84% <0%> (-0.31%) ⬇️
Lib/test/test_strptime.py 94.76% <0%> (-0.27%) ⬇️
Lib/test/test_ftplib.py 95.72% <0%> (-0.26%) ⬇️
... and 103 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55ace65...0c33759. Read the comment docs.

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@brettcannon
Copy link
Member

Can I ask if a CLA was eventually verified as being signed before merging this?

@Mariatta
Copy link
Member

Mariatta commented Jun 6, 2017

@brettcannon I asked the PR author in bpo-30303 about this.
It seems that @louisom is the same person as @mlouielu, and @mlouielu has signed the CLA.

@mlouielu
Copy link
Contributor

mlouielu commented Jun 6, 2017

@louisom is my previous account, does b.p.o. support comma split (louisom, mlouielu) at the detail page?

@mlouielu
Copy link
Contributor

mlouielu commented Jun 6, 2017

@Mariatta I've add another CLA to @louisom, please help to verify this, thanks!

@brettcannon
Copy link
Member

@Mariatta @mlouielu thanks for the clarification!

@miss-islington
Copy link
Contributor

🐍🍒⛏🤖 Thanks @louisom for the PR, and @terryjreedy for merging it 🌮🎉.I'm working now to backport this PR to: 3.6.

@miss-islington
Copy link
Contributor

Sorry, @louisom and @terryjreedy, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.

@terryjreedy
Copy link
Member

The backport error is because this was backported already in #1916. (And the file has been refactored since.) I removed the label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants