Issue 18504: IDLE: Improve Mock_Text (original) (raw)

Issue18504

Created on 2013-07-19 13:00 by JayKrish, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
decodeChecklist.txt JayKrish,2013-07-19 13:02
decodeTest.py JayKrish,2013-07-19 13:04
mocktk_decodeByRE1.patch JayKrish,2013-07-26 20:35 review
mock-text-_decode.diff Saimadhav.Heblikar,2014-06-01 14:44 review
Messages (4)
msg193358 - (view) Author: R. Jayakrishnan (JayKrish) * Date: 2013-07-19 13:00
Following the Idle: mock Text class and test thereof created #18365 I am trying to improve the _decode function because most of the Idletests needs the mock text and requires some more features to handle indexes. Started improving the mockText _decode method while writing unit test for AutoExpand.py at #18292. For now I want the mock text to decode following indexes: line.char, insert, end, +-#c/chars, lineend, linestart, wordstart, wordend For this I am trying to write regular expressions to extract the parts of index. The submitted decodeTest.py is a sample script to show how my regular expression starts manipulating the decoding of indexes. I have attached a checklist of several indexes. So you can easily run them and get an understanding of my approach.
msg193395 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-07-20 02:31
Further changes should be aimed at actual idlelib uses. Wordstart and wordend are used once each in AutoExpand.py (and wordstart a couple of times for tag.start positions). So forget them. Does idlelib really have indexes like "2.3 + 1c" ('2.4'), "2.3-1c" ('2.2'), and "22.33-1chars" ('22.32')? The grammar we need to parse is something like index := base modifier* # nearly always 0, 1, few 2, one 3 times, so index := base modifier{0:3} index := base modmaybe modmaybe modmaybe base := numpair | mark numpair := int '.' ( int 'end' ) mark := 'end' 'insert' 'iomark' 'my_anchor' 'sel.first' sel.last # parts tags but this should work modmaybe := modifier '' modifier := ' linestart' ' lineend' incr incr := ' '* ('+' '-') ' '* int ('c' 'line') # Could change the one 'char' to 'c' Rather than parse an entire index at once, parse, interpret as position, and remove base from input. While remainder, parse, apply to position, and remove from remainder. Whether the parsing is done with base and modifier REs with groups or code or some mixture does not much matter.
msg193740 - (view) Author: R. Jayakrishnan (JayKrish) * Date: 2013-07-26 20:35
Yes,correcting myself. I should aim indexes which actual idlelib uses. Thank you Terry for the grammar. Fighting with the index parsing last week, and finally came up with a level to break the index into base and modifier and decode it along with using regular expressions. Now the mock_tk attached at this patch passes all the existing test cases, and failing the new test I have written on text_test The problem now I am dealing with is, there are four exceeding conditions I have to handle which make errors. 1.returning line < 0 2.returning line > last line 3.returning char < 0 4.returning char > its line length For example, in parsing base the return line may exceed last line but the modifier will say '-2lines' doing that, now the return line is not exceeding last line.
msg219502 - (view) Author: Saimadhav Heblikar (Saimadhav.Heblikar) * Date: 2014-06-01 14:44
This patch tries to enable mock_Tk.Text._decode to handle the following patterns insert linestart insert lineend insert wordstart insert wordend insert +x chars insert -x chars These additions are required for testing AutoExpand and are written keeping the same in mind. Also, adds respective tests for test_decode in test_text.py. I would like to know if my approach is acceptable or whether it needs changes. is about adding unittests for AutoExpand. (A 2.7 patch will be submitted once the above changes become acceptable)
History
Date User Action Args
2022-04-11 14:57:48 admin set github: 62704
2020-06-07 20:34:42 terry.reedy set versions: + Python 3.10, - Python 3.6, Python 3.7
2017-06-19 23:30:45 terry.reedy set title: IDLE:Improvements- Improving Mock_Text -> IDLE: Improve Mock_Text
2017-06-19 23:28:16 terry.reedy set components: + IDLEversions: + Python 3.6, Python 3.7, - Python 2.7, Python 3.3, Python 3.4
2014-06-01 14:44:35 Saimadhav.Heblikar set files: + mock-text-_decode.diffnosy: + jesstess, Saimadhav.Heblikarmessages: +
2013-08-10 14:59:02 ezio.melotti set nosy: + ezio.melottistage: test needed -> patch review
2013-07-26 20:35:42 JayKrish set files: + mocktk_decodeByRE1.patchkeywords: + patchmessages: +
2013-07-23 03:11:05 JayKrish set nosy: + Todd.Rovito
2013-07-23 03:09:20 philwebster set nosy: + philwebster
2013-07-20 02:31:42 terry.reedy set assignee: terry.reedytype: enhancementversions: + Python 2.7, Python 3.3, Python 3.4nosy: + terry.reedymessages: + stage: test needed
2013-07-19 13:04:43 JayKrish set files: + decodeTest.py
2013-07-19 13:04:12 JayKrish set files: - decodeTest.py
2013-07-19 13:02:01 JayKrish set files: + decodeChecklist.txt
2013-07-19 13:00:52 JayKrish create