##// END OF EJS Templates
Pop the last if path ends with slash
Inception95 -
Show More
@@ -42,6 +42,7 b' def _elide(string, *, min_elide=30):'
42
42
43 object_parts = string.split('.')
43 object_parts = string.split('.')
44 file_parts = string.split(os.sep)
44 file_parts = string.split(os.sep)
45 file_parts.pop() if file_parts[-1] == '' else None
45
46
46 if len(object_parts) > 3:
47 if len(object_parts) > 3:
47 return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(object_parts[0], object_parts[1][0], object_parts[-2][-1], object_parts[-1])
48 return '{}.{}\N{HORIZONTAL ELLIPSIS}{}.{}'.format(object_parts[0], object_parts[1][0], object_parts[-2][-1], object_parts[-1])
@@ -5,6 +5,7 b''
5
5
6 import sys
6 import sys
7 import unittest
7 import unittest
8 import os
8
9
9 from IPython.core.inputtransformer import InputTransformer
10 from IPython.core.inputtransformer import InputTransformer
10 from IPython.testing import tools as tt
11 from IPython.testing import tools as tt
@@ -20,6 +21,10 b' class TestElide(unittest.TestCase):'
20 _elide('concatenate((a1, a2, ..), . axis') # do not raise
21 _elide('concatenate((a1, a2, ..), . axis') # do not raise
21 nt.assert_equal(_elide('aaaa.bbbb.ccccc.dddddd.eeeee.fffff.gggggg.hhhhhh'), 'aaaa.b…g.hhhhhh')
22 nt.assert_equal(_elide('aaaa.bbbb.ccccc.dddddd.eeeee.fffff.gggggg.hhhhhh'), 'aaaa.b…g.hhhhhh')
22
23
24 test_string = os.sep.join(['', 10*'a', 10*'b', 10*'c', ''])
25 expect_stirng = os.sep + 'a' + '\N{HORIZONTAL ELLIPSIS}' + 'b' + os.sep + 10*'c'
26 nt.assert_equal(_elide(test_string), expect_stirng)
27
23
28
24 class TestContextAwareCompletion(unittest.TestCase):
29 class TestContextAwareCompletion(unittest.TestCase):
25
30
General Comments 0
You need to be logged in to leave comments. Login now