diff --git a/IPython/utils/tests/test_text.py b/IPython/utils/tests/test_text.py index 8822262..fa4c7fb 100644 --- a/IPython/utils/tests/test_text.py +++ b/IPython/utils/tests/test_text.py @@ -149,6 +149,9 @@ def test_long_substr2(): data = ['abc', 'abd', 'abf', 'ab'] nt.assert_equals(text.long_substr(data), 'ab') +def test_long_substr_empty(): + data = [] + nt.assert_equals(text.long_substr(data), '') def test_strip_email(): src = """\ diff --git a/IPython/utils/text.py b/IPython/utils/text.py index f66962a..b53f826 100644 --- a/IPython/utils/text.py +++ b/IPython/utils/text.py @@ -553,7 +553,7 @@ def long_substr(data): for j in range(len(data[0])-i+1): if j > len(substr) and all(data[0][i:i+j] in x for x in data): substr = data[0][i:i+j] - else: + elif len(data) == 1: substr = data[0] return substr