##// END OF EJS Templates
[terminal][tests][interactiveshell] Remove nose
Samuel Gaist -
Show More
@@ -12,29 +12,42 b' from IPython.testing import tools as tt'
12 from IPython.utils.capture import capture_output
12 from IPython.utils.capture import capture_output
13
13
14 from IPython.terminal.ptutils import _elide, _adjust_completion_text_based_on_context
14 from IPython.terminal.ptutils import _elide, _adjust_completion_text_based_on_context
15 import nose.tools as nt
16
15
17 class TestElide(unittest.TestCase):
18
16
17 class TestElide(unittest.TestCase):
19 def test_elide(self):
18 def test_elide(self):
20 _elide('concatenate((a1, a2, ...), axis', '') # do not raise
19 _elide("concatenate((a1, a2, ...), axis", "") # do not raise
21 _elide('concatenate((a1, a2, ..), . axis', '') # do not raise
20 _elide("concatenate((a1, a2, ..), . axis", "") # do not raise
22 nt.assert_equal(_elide('aaaa.bbbb.ccccc.dddddd.eeeee.fffff.gggggg.hhhhhh',''), 'aaaa.b…g.hhhhhh')
21 self.assertEqual(
23
22 _elide("aaaa.bbbb.ccccc.dddddd.eeeee.fffff.gggggg.hhhhhh", ""),
24 test_string = os.sep.join(['', 10*'a', 10*'b', 10*'c', ''])
23 "aaaa.b…g.hhhhhh",
25 expect_stirng = os.sep + 'a' + '\N{HORIZONTAL ELLIPSIS}' + 'b' + os.sep + 10*'c'
24 )
26 nt.assert_equal(_elide(test_string, ''), expect_stirng)
25
26 test_string = os.sep.join(["", 10 * "a", 10 * "b", 10 * "c", ""])
27 expect_stirng = (
28 os.sep + "a" + "\N{HORIZONTAL ELLIPSIS}" + "b" + os.sep + 10 * "c"
29 )
30 self.assertEqual(_elide(test_string, ""), expect_stirng)
27
31
28 def test_elide_typed_normal(self):
32 def test_elide_typed_normal(self):
29 nt.assert_equal(_elide('the quick brown fox jumped over the lazy dog', 'the quick brown fox', min_elide=10), 'the…fox jumped over the lazy dog')
33 self.assertEqual(
30
34 _elide(
35 "the quick brown fox jumped over the lazy dog",
36 "the quick brown fox",
37 min_elide=10,
38 ),
39 "the…fox jumped over the lazy dog",
40 )
31
41
32 def test_elide_typed_short_match(self):
42 def test_elide_typed_short_match(self):
33 """
43 """
34 if the match is too short we don't elide.
44 if the match is too short we don't elide.
35 avoid the "the...the"
45 avoid the "the...the"
36 """
46 """
37 nt.assert_equal(_elide('the quick brown fox jumped over the lazy dog', 'the', min_elide=10), 'the quick brown fox jumped over the lazy dog')
47 self.assertEqual(
48 _elide("the quick brown fox jumped over the lazy dog", "the", min_elide=10),
49 "the quick brown fox jumped over the lazy dog",
50 )
38
51
39 def test_elide_typed_no_match(self):
52 def test_elide_typed_no_match(self):
40 """
53 """
@@ -42,22 +55,41 b' class TestElide(unittest.TestCase):'
42 avoid the "the...the"
55 avoid the "the...the"
43 """
56 """
44 # here we typed red instead of brown
57 # here we typed red instead of brown
45 nt.assert_equal(_elide('the quick brown fox jumped over the lazy dog', 'the quick red fox', min_elide=10), 'the quick brown fox jumped over the lazy dog')
58 self.assertEqual(
59 _elide(
60 "the quick brown fox jumped over the lazy dog",
61 "the quick red fox",
62 min_elide=10,
63 ),
64 "the quick brown fox jumped over the lazy dog",
65 )
46
66
47 class TestContextAwareCompletion(unittest.TestCase):
48
67
68 class TestContextAwareCompletion(unittest.TestCase):
49 def test_adjust_completion_text_based_on_context(self):
69 def test_adjust_completion_text_based_on_context(self):
50 # Adjusted case
70 # Adjusted case
51 nt.assert_equal(_adjust_completion_text_based_on_context('arg1=', 'func1(a=)', 7), 'arg1')
71 self.assertEqual(
72 _adjust_completion_text_based_on_context("arg1=", "func1(a=)", 7), "arg1"
73 )
52
74
53 # Untouched cases
75 # Untouched cases
54 nt.assert_equal(_adjust_completion_text_based_on_context('arg1=', 'func1(a)', 7), 'arg1=')
76 self.assertEqual(
55 nt.assert_equal(_adjust_completion_text_based_on_context('arg1=', 'func1(a', 7), 'arg1=')
77 _adjust_completion_text_based_on_context("arg1=", "func1(a)", 7), "arg1="
56 nt.assert_equal(_adjust_completion_text_based_on_context('%magic', 'func1(a=)', 7), '%magic')
78 )
57 nt.assert_equal(_adjust_completion_text_based_on_context('func2', 'func1(a=)', 7), 'func2')
79 self.assertEqual(
80 _adjust_completion_text_based_on_context("arg1=", "func1(a", 7), "arg1="
81 )
82 self.assertEqual(
83 _adjust_completion_text_based_on_context("%magic", "func1(a=)", 7), "%magic"
84 )
85 self.assertEqual(
86 _adjust_completion_text_based_on_context("func2", "func1(a=)", 7), "func2"
87 )
88
58
89
59 # Decorator for interaction loop tests -----------------------------------------
90 # Decorator for interaction loop tests -----------------------------------------
60
91
92
61 class mock_input_helper(object):
93 class mock_input_helper(object):
62 """Machinery for tests of the main interact loop.
94 """Machinery for tests of the main interact loop.
63
95
General Comments 0
You need to be logged in to leave comments. Login now