Show More
@@ -4,7 +4,7 b'' | |||||
4 |
|
4 | |||
5 | import nose.tools as nt |
|
5 | import nose.tools as nt | |
6 |
|
6 | |||
7 | from IPython.utils.tokenutil import token_at_cursor |
|
7 | from IPython.utils.tokenutil import token_at_cursor, line_at_cursor | |
8 |
|
8 | |||
9 | def expect_token(expected, cell, cursor_pos): |
|
9 | def expect_token(expected, cell, cursor_pos): | |
10 | token = token_at_cursor(cell, cursor_pos) |
|
10 | token = token_at_cursor(cell, cursor_pos) | |
@@ -68,3 +68,9 b' def test_attrs():' | |||||
68 | expected = 'obj.attr.subattr' |
|
68 | expected = 'obj.attr.subattr' | |
69 | for i in range(idx, len(cell)): |
|
69 | for i in range(idx, len(cell)): | |
70 | expect_token(expected, cell, i) |
|
70 | expect_token(expected, cell, i) | |
|
71 | ||||
|
72 | def test_line_at_cursor(): | |||
|
73 | cell = "" | |||
|
74 | (line, offset) = line_at_cursor(cell, cursor_pos=11) | |||
|
75 | assert line == "", ("Expected '', got %r" % line) | |||
|
76 | assert offset == 0, ("Expected '', got %r" % line) |
@@ -49,6 +49,8 b' def line_at_cursor(cell, cursor_pos=0):' | |||||
49 | if next_offset >= cursor_pos: |
|
49 | if next_offset >= cursor_pos: | |
50 | break |
|
50 | break | |
51 | offset = next_offset |
|
51 | offset = next_offset | |
|
52 | else: | |||
|
53 | line = "" | |||
52 | return (line, offset) |
|
54 | return (line, offset) | |
53 |
|
55 | |||
54 | def token_at_cursor(cell, cursor_pos=0): |
|
56 | def token_at_cursor(cell, cursor_pos=0): |
General Comments 0
You need to be logged in to leave comments.
Login now