[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-08-27 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-08-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:


New changeset 5c89c2fd8a0be0ad2f89f084775c5f9f76687237 by Terry Jan Reedy in 
branch '3.6':
[3.6] bpo-30617: IDLE: docstrings and unittest for outwin.py (GH-2046) (#3223)
https://github.com/python/cpython/commit/5c89c2fd8a0be0ad2f89f084775c5f9f76687237


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-08-27 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
pull_requests: +3265

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-08-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:


New changeset 998f4966bf0c591f3e8b3d07eccad7501f60f524 by Terry Jan Reedy 
(Cheryl Sabella) in branch 'master':
bpo-30617: IDLE: docstrings and unittest for outwin.py (#2046)
https://github.com/python/cpython/commit/998f4966bf0c591f3e8b3d07eccad7501f60f524


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-08-27 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
pull_requests: +3261

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-06-12 Thread Cheryl Sabella

Cheryl Sabella added the comment:

Thanks!

I've added more unittests.  They are passing, but I'm getting a callback error 
that I don't understand.  The same _utest flag that's on the textview dialog 
didn't seem to work and I was just blindly trying things without success.  
Also, the window is briefly opening and closing on the screen.  Any suggestions 
on where I should look next?

B3 below.  Thanks for the link to that other message.  Combining that with some 
comments on SO, I tried to find unicode that would be selected by \d and would 
fail with int(), but couldn't find any.  However, I also realized that the 
try/except is checking for a TypeError and not a ValueError.  I went and looked 
at the change history for OutputWindow, but couldn't see anything that would 
show why there might be a TypeError check here.  If the match group is None, it 
wouldn't get this far in the code.

Additionally,
1.  I removed 'from tkinter import *' because it wasn't being used.
2.  I changed 'import tkinter.messagebox as tkMessageBox' per issue 30422.
3.  There were two lines:
edit = self.flist.open(filename)
edit.gotoline(lineno)
but flist had a gotofileline() that did the same thing.  In the historical 
code, the 'edit = ' line had and 'or', so maybe that's why it was separated.
4.  *args on the __init__.  I've seen *args used for passing config options and 
things like that, but I don't understand why it would be preferable here 
instead of listing the 4 arguments explicitly.

Thanks!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-06-09 Thread Terry J. Reedy

Terry J. Reedy added the comment:

A1: yes, add
if __name__ == '__main__':
import unittest
unittest.main('idlelib.idle_test.test_outwin', verbosity=2, exit=False)

I will have to think about whether and how to add an htest.  The grep (find in 
files) test actually displays greps results in an outwin, and suggests rt 
clicking within the result window, so it really tests both grep and outwin 
modules.  Maybe this htest should be split.

A2. The current code tests whether the file exists *and* can be read.  It must 
have been read to appear in grep output.  But I am not sure this is true for 
names in tracebacks.  

B1. This is first test of an editor window.  Having the least code, it it 
probably the best place to start and learn ;-).

B2. The class level patterns are compiled to an instance array for each 
instance in which a user tries to go to file/line.  That should be most.  This 
looks to me like an attempted optimization (don't compile unless needed) that 
is a pessimization.  I think either A) the compiled patterns should be stored 
back on the class or B) raw and compiled patterns should be stored at module 
level.  They are not instance attributes and not really class attributes 
either.  Also, the code blocks that create file_line_progs and use it really 
belong in module level functions.  So lets try B.

Move stuff from class to module scope:

file_line_pats = [
   ...]
file_line_progs = None

def compile_progs():
global file_line_progs
file_line_progs = [re.compile(pat, re.IGNORECASE)
   for pat in file_line_pats]

def find_file_line(line_of_text):


# and simply method
   def goto_file_line(self, event=None): # in class
if not file_line_progs:
compile_progs()

Test for compile_progs (:
for pat, regex in zip(file_line_pats, file_line_progs):
assertEqual(regex.pattern, pat)

Then feed find_file_line lines that should and should not match.  Try to find 
at least 1 true-to-life line for each pattern. 

B3. In re, \d "matches any Unicode decimal digit (that is, any character in 
Unicode character category [Nd])". Builtin int (at least) accepts strings 
consisting of string literal, which is restricted to ascii digit. msg90878 says 
"int and float currently accept characters in category 'Nd'".  I am not sure if 
that mean *all* Nd chars.  We could test.  If the exception is impossible, it 
should not be caught.  (Dead code should be removed, but we must be sure it is 
dead ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-06-09 Thread Cheryl Sabella

Cheryl Sabella added the comment:

Questions about outwin.py:

1. Should a main() be added for htest and unittest?

2. In _file_line_helper, to test if the file exists, the file is opened, then 
closed.  Would os.path.isfile work here?

Questions about tests:
1. OutputWindow is an EditorWindow and EditorWindow has a superclass of Object. 
 I didn't know how to make tests to test the text binding for goto-file-line.  
Or how to test the other functions.  I tried emulating the dialogs, but 
couldn't get it to work.  Is there any existing test for another module I can 
study and copy?  EditorWindow didn't really have any tests for this yet, but if 
I learn how to do it here, I can apply it there.

2. The `goto_line_file` function compiles the class attribute for the matching 
patterns `file_line_pats` which is then used by `_file_line_helper`.  I had 
trouble writing a test just for the helper without copying this pattern compile 
code from the other function.  I wasn't sure how to get around that.  Are the 
patterns at the class level so that they are cahced for all the calls?  How 
should I change the test?  Can the patterns be compiled inside 
`_file_line_helper`?

3.  Is the test of `_file_line_helper` the right way to go with the tests?  
Should examples of each pattern be included?  I didn't add a test for the 
TypeError because the pattens didn't seem like they would match on anything but 
digits.  Should I add a pattern for testing just for code coverage?

Thanks!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-06-09 Thread Cheryl Sabella

New submission from Cheryl Sabella:

For issue 30422.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-06-09 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
pull_requests: +2108

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30617] IDLE: Add docstrings and unittests to outwin.py

2017-06-09 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
assignee: terry.reedy
components: IDLE
nosy: csabella, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE: Add docstrings and unittests to outwin.py
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com