diff --git a/IPython/terminal/tests/test_interactivshell.py b/IPython/terminal/tests/test_interactivshell.py index 640e5d4..763ccc9 100644 --- a/IPython/terminal/tests/test_interactivshell.py +++ b/IPython/terminal/tests/test_interactivshell.py @@ -12,29 +12,42 @@ from IPython.testing import tools as tt from IPython.utils.capture import capture_output from IPython.terminal.ptutils import _elide, _adjust_completion_text_based_on_context -import nose.tools as nt -class TestElide(unittest.TestCase): +class TestElide(unittest.TestCase): def test_elide(self): - _elide('concatenate((a1, a2, ...), axis', '') # do not raise - _elide('concatenate((a1, a2, ..), . axis', '') # do not raise - nt.assert_equal(_elide('aaaa.bbbb.ccccc.dddddd.eeeee.fffff.gggggg.hhhhhh',''), 'aaaa.b…g.hhhhhh') - - test_string = os.sep.join(['', 10*'a', 10*'b', 10*'c', '']) - expect_stirng = os.sep + 'a' + '\N{HORIZONTAL ELLIPSIS}' + 'b' + os.sep + 10*'c' - nt.assert_equal(_elide(test_string, ''), expect_stirng) + _elide("concatenate((a1, a2, ...), axis", "") # do not raise + _elide("concatenate((a1, a2, ..), . axis", "") # do not raise + self.assertEqual( + _elide("aaaa.bbbb.ccccc.dddddd.eeeee.fffff.gggggg.hhhhhh", ""), + "aaaa.b…g.hhhhhh", + ) + + test_string = os.sep.join(["", 10 * "a", 10 * "b", 10 * "c", ""]) + expect_stirng = ( + os.sep + "a" + "\N{HORIZONTAL ELLIPSIS}" + "b" + os.sep + 10 * "c" + ) + self.assertEqual(_elide(test_string, ""), expect_stirng) def test_elide_typed_normal(self): - 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') - + self.assertEqual( + _elide( + "the quick brown fox jumped over the lazy dog", + "the quick brown fox", + min_elide=10, + ), + "the…fox jumped over the lazy dog", + ) def test_elide_typed_short_match(self): """ if the match is too short we don't elide. avoid the "the...the" """ - 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') + self.assertEqual( + _elide("the quick brown fox jumped over the lazy dog", "the", min_elide=10), + "the quick brown fox jumped over the lazy dog", + ) def test_elide_typed_no_match(self): """ @@ -42,22 +55,41 @@ class TestElide(unittest.TestCase): avoid the "the...the" """ # here we typed red instead of brown - 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') + self.assertEqual( + _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", + ) -class TestContextAwareCompletion(unittest.TestCase): +class TestContextAwareCompletion(unittest.TestCase): def test_adjust_completion_text_based_on_context(self): # Adjusted case - nt.assert_equal(_adjust_completion_text_based_on_context('arg1=', 'func1(a=)', 7), 'arg1') + self.assertEqual( + _adjust_completion_text_based_on_context("arg1=", "func1(a=)", 7), "arg1" + ) # Untouched cases - nt.assert_equal(_adjust_completion_text_based_on_context('arg1=', 'func1(a)', 7), 'arg1=') - nt.assert_equal(_adjust_completion_text_based_on_context('arg1=', 'func1(a', 7), 'arg1=') - nt.assert_equal(_adjust_completion_text_based_on_context('%magic', 'func1(a=)', 7), '%magic') - nt.assert_equal(_adjust_completion_text_based_on_context('func2', 'func1(a=)', 7), 'func2') + self.assertEqual( + _adjust_completion_text_based_on_context("arg1=", "func1(a)", 7), "arg1=" + ) + self.assertEqual( + _adjust_completion_text_based_on_context("arg1=", "func1(a", 7), "arg1=" + ) + self.assertEqual( + _adjust_completion_text_based_on_context("%magic", "func1(a=)", 7), "%magic" + ) + self.assertEqual( + _adjust_completion_text_based_on_context("func2", "func1(a=)", 7), "func2" + ) + # Decorator for interaction loop tests ----------------------------------------- + class mock_input_helper(object): """Machinery for tests of the main interact loop.