##// END OF EJS Templates
[utils][tests][tokenutil] Remove nose
Samuel Gaist -
Show More
@@ -2,7 +2,6 b''
2 # Copyright (c) IPython Development Team.
2 # Copyright (c) IPython Development Team.
3 # Distributed under the terms of the Modified BSD License.
3 # Distributed under the terms of the Modified BSD License.
4
4
5 import nose.tools as nt
6 import pytest
5 import pytest
7 from IPython.testing.decorators import skip_iptest_but_not_pytest
6 from IPython.testing.decorators import skip_iptest_but_not_pytest
8
7
@@ -17,13 +16,16 b' def expect_token(expected, cell, cursor_pos):'
17 else:
16 else:
18 offset += len(line)+1
17 offset += len(line)+1
19 column = cursor_pos - offset
18 column = cursor_pos - offset
20 line_with_cursor = '%s|%s' % (line[:column], line[column:])
19 line_with_cursor = "%s|%s" % (line[:column], line[column:])
21 nt.assert_equal(token, expected,
20 assert token == expected, "Expected %r, got %r in: %r (pos %i)" % (
22 "Expected %r, got %r in: %r (pos %i)" % (
21 expected,
23 expected, token, line_with_cursor, cursor_pos)
22 token,
23 line_with_cursor,
24 cursor_pos,
24 )
25 )
25
26
26 def test_simple():
27
28 def test_simple():
27 cell = "foo"
29 cell = "foo"
28 for i in range(len(cell)):
30 for i in range(len(cell)):
29 expect_token("foo", cell, i)
31 expect_token("foo", cell, i)
@@ -107,20 +109,20 b' def test_attrs():'
107 def test_line_at_cursor():
109 def test_line_at_cursor():
108 cell = ""
110 cell = ""
109 (line, offset) = line_at_cursor(cell, cursor_pos=11)
111 (line, offset) = line_at_cursor(cell, cursor_pos=11)
110 nt.assert_equal(line, "")
112 assert line == ""
111 nt.assert_equal(offset, 0)
113 assert offset == 0
112
114
113 # The position after a newline should be the start of the following line.
115 # The position after a newline should be the start of the following line.
114 cell = "One\nTwo\n"
116 cell = "One\nTwo\n"
115 (line, offset) = line_at_cursor(cell, cursor_pos=4)
117 (line, offset) = line_at_cursor(cell, cursor_pos=4)
116 nt.assert_equal(line, "Two\n")
118 assert line == "Two\n"
117 nt.assert_equal(offset, 4)
119 assert offset == 4
118
120
119 # The end of a cell should be on the last line
121 # The end of a cell should be on the last line
120 cell = "pri\npri"
122 cell = "pri\npri"
121 (line, offset) = line_at_cursor(cell, cursor_pos=7)
123 (line, offset) = line_at_cursor(cell, cursor_pos=7)
122 nt.assert_equal(line, "pri")
124 assert line == "pri"
123 nt.assert_equal(offset, 4)
125 assert offset == 4
124
126
125
127
126 @pytest.mark.parametrize(
128 @pytest.mark.parametrize(
General Comments 0
You need to be logged in to leave comments. Login now