diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-06-16 19:01:01 -0400 |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-06-16 19:01:01 -0400 |
commit | 10b1c7cc8fa201df48c2c502efe62ac5475ceb18 (patch) | |
tree | ae4f10f8c93c021d6acd95352a4fcd01750e99c3 /Lib/idlelib/HyperParser.py | |
parent | bc434e205261fbe9afc45f5f601d2238ffbe09f9 (diff) | |
download | cpython-git-10b1c7cc8fa201df48c2c502efe62ac5475ceb18.tar.gz |
Issue #21686: add unittest for idlelib.HyperParser. Original patch by Saimadhav
Heblikar. Correct a minor 3.x bug in HyperParser discovered by testing.
Diffstat (limited to 'Lib/idlelib/HyperParser.py')
-rw-r--r-- | Lib/idlelib/HyperParser.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Lib/idlelib/HyperParser.py b/Lib/idlelib/HyperParser.py index bd92807af8..d376568fc9 100644 --- a/Lib/idlelib/HyperParser.py +++ b/Lib/idlelib/HyperParser.py @@ -1,4 +1,4 @@ -"""Provide advanced parsing abilities for the ParenMatch and other extensions. +"""Provide advanced parsing abilities for ParenMatch and other extensions. HyperParser uses PyParser. PyParser mostly gives information on the proper indentation of code. HyperParser gives additional information on @@ -88,7 +88,7 @@ class HyperParser: self.indexbracket += 1 def is_in_string(self): - """Is the index given to the HyperParser is in a string?""" + """Is the index given to the HyperParser in a string?""" # The bracket to which we belong should be an opener. # If it's an opener, it has to have a character. return (self.isopener[self.indexbracket] and @@ -96,7 +96,7 @@ class HyperParser: in ('"', "'")) def is_in_code(self): - """Is the index given to the HyperParser is in a normal code?""" + """Is the index given to the HyperParser in normal code?""" return (not self.isopener[self.indexbracket] or self.rawtext[self.bracketing[self.indexbracket][0]] not in ('#', '"', "'")) @@ -158,7 +158,8 @@ class HyperParser: while i > limit and str[i-1] in self._id_chars: i -= 1 if (i < pos and (str[i] not in self._id_first_chars or - keyword.iskeyword(str[i:pos]))): + (keyword.iskeyword(str[i:pos]) and + str[i:pos] not in {'None', 'False', 'True'}))): i = pos return pos - i @@ -248,3 +249,8 @@ class HyperParser: break return rawtext[last_identifier_pos:self.indexinrawtext] + + +if __name__ == '__main__': + import unittest + unittest.main('idlelib.idle_test.test_hyperparser', verbosity=2) |