Show More
@@ -147,10 +147,6 b' class PtkHistoryAdapter(History):' | |||
|
147 | 147 | |
|
148 | 148 | """ |
|
149 | 149 | |
|
150 | auto_suggest: UnionType[ | |
|
151 | AutoSuggestFromHistory, NavigableAutoSuggestFromHistory, None | |
|
152 | ] | |
|
153 | ||
|
154 | 150 | def __init__(self, shell): |
|
155 | 151 | super().__init__() |
|
156 | 152 | self.shell = shell |
@@ -193,6 +189,9 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
193 | 189 | ).tag(config=True) |
|
194 | 190 | |
|
195 | 191 | pt_app: UnionType[PromptSession, None] = None |
|
192 | auto_suggest: UnionType[ | |
|
193 | AutoSuggestFromHistory, NavigableAutoSuggestFromHistory, None | |
|
194 | ] = None | |
|
196 | 195 | debugger_history = None |
|
197 | 196 | |
|
198 | 197 | debugger_history_file = Unicode( |
@@ -685,7 +684,6 b' class TerminalInteractiveShell(InteractiveShell):' | |||
|
685 | 684 | |
|
686 | 685 | def __init__(self, *args, **kwargs) -> None: |
|
687 | 686 | super(TerminalInteractiveShell, self).__init__(*args, **kwargs) |
|
688 | self.auto_suggest = None | |
|
689 | 687 | self._set_autosuggestions(self.autosuggestions_provider) |
|
690 | 688 | self.init_prompt_toolkit_cli() |
|
691 | 689 | self.init_term_title() |
@@ -7,11 +7,25 b' import sys' | |||
|
7 | 7 | import unittest |
|
8 | 8 | import os |
|
9 | 9 | |
|
10 | from prompt_toolkit.auto_suggest import AutoSuggestFromHistory | |
|
11 | ||
|
10 | 12 | from IPython.core.inputtransformer import InputTransformer |
|
11 | 13 | from IPython.testing import tools as tt |
|
12 | 14 | from IPython.utils.capture import capture_output |
|
13 | 15 | |
|
14 | 16 | from IPython.terminal.ptutils import _elide, _adjust_completion_text_based_on_context |
|
17 | from IPython.terminal.shortcuts.auto_suggest import NavigableAutoSuggestFromHistory | |
|
18 | ||
|
19 | ||
|
20 | class TestAutoSuggest(unittest.TestCase): | |
|
21 | def test_changing_provider(self): | |
|
22 | ip = get_ipython() | |
|
23 | ip.autosuggestions_provider = None | |
|
24 | self.assertEqual(ip.auto_suggest, None) | |
|
25 | ip.autosuggestions_provider = "AutoSuggestFromHistory" | |
|
26 | self.assertIsInstance(ip.auto_suggest, AutoSuggestFromHistory) | |
|
27 | ip.autosuggestions_provider = "NavigableAutoSuggestFromHistory" | |
|
28 | self.assertIsInstance(ip.auto_suggest, NavigableAutoSuggestFromHistory) | |
|
15 | 29 | |
|
16 | 30 | |
|
17 | 31 | class TestElide(unittest.TestCase): |
@@ -24,10 +38,10 b' class TestElide(unittest.TestCase):' | |||
|
24 | 38 | ) |
|
25 | 39 | |
|
26 | 40 | test_string = os.sep.join(["", 10 * "a", 10 * "b", 10 * "c", ""]) |
|
27 |
expect_st |
|
|
41 | expect_string = ( | |
|
28 | 42 | os.sep + "a" + "\N{HORIZONTAL ELLIPSIS}" + "b" + os.sep + 10 * "c" |
|
29 | 43 | ) |
|
30 |
self.assertEqual(_elide(test_string, ""), expect_st |
|
|
44 | self.assertEqual(_elide(test_string, ""), expect_string) | |
|
31 | 45 | |
|
32 | 46 | def test_elide_typed_normal(self): |
|
33 | 47 | self.assertEqual( |
General Comments 0
You need to be logged in to leave comments.
Login now