##// END OF EJS Templates
Merge pull request #12127 from meeseeksmachine/auto-backport-of-pr-12122-on-7.x...
Matthias Bussonnier -
r25515:5b0df90e merge
parent child Browse files
Show More
@@ -42,6 +42,8 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 if file_parts[-1] == '':
46 file_parts.pop()
45
47
46 if len(object_parts) > 3:
48 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])
49 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
@@ -19,6 +20,10 b' class TestElide(unittest.TestCase):'
19 _elide('concatenate((a1, a2, ...), axis') # do not raise
20 _elide('concatenate((a1, a2, ...), axis') # do not raise
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')
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)
22
27
23
28
24 class TestContextAwareCompletion(unittest.TestCase):
29 class TestContextAwareCompletion(unittest.TestCase):
General Comments 0
You need to be logged in to leave comments. Login now