Skip to content

Commit 5df09e4

Browse files
fix three last failing tests
1 parent 0f6ce9c commit 5df09e4

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

bpython/line.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ def current_dict(cursor_offset, line):
3838
return None
3939

4040
def current_string(cursor_offset, line):
41-
"""If inside a string, return the string (excluding quotes)
41+
"""If inside a string of nonzero length, return the string (excluding quotes)
4242
4343
Weaker than bpython.Repl's current_string, because that checks that a string is a string
4444
based on previous lines in the buffer"""
45-
for m in re.finditer('''(?P<open>(?:""")|"|(?:''\')|')(?:((?P<closed>.*?)(?P=open))|(?P<unclosed>.*))''', line):
45+
for m in re.finditer('''(?P<open>(?:""")|"|(?:''\')|')(?:((?P<closed>.+?)(?P=open))|(?P<unclosed>.+))''', line):
4646
i = 3 if m.group(3) else 4
47-
if m.start(i) < cursor_offset and m.end(i) >= cursor_offset:
47+
if m.start(i) <= cursor_offset and m.end(i) >= cursor_offset:
4848
return m.start(i), m.end(i), m.group(i)
4949
return None
5050

bpython/test/test_keys.py

100755100644
File mode changed.

bpython/test/test_line_properties.py

100755100644
File mode changed.

bpython/test/test_repl.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
def skip(f):
99
return lambda self: None
1010

11+
py3 = (sys.version_info[0] == 3)
12+
1113
from bpython import config, repl, cli, autocomplete
1214

1315
def setup_config(conf):
@@ -399,7 +401,10 @@ def setUp(self):
399401
# 3 Types of tab complete
400402
def test_simple_tab_complete(self):
401403
self.repl.matches_iter = MagicMock()
402-
self.repl.matches_iter.__nonzero__.return_value = False
404+
if py3:
405+
self.repl.matches_iter.__bool__.return_value = False
406+
else:
407+
self.repl.matches_iter.__nonzero__.return_value = False
403408
self.repl.complete = Mock()
404409
self.repl.print_line = Mock()
405410
self.repl.matches_iter.is_cseq.return_value = False

0 commit comments

Comments
 (0)