##// END OF EJS Templates
Fix test after rebase...
Matthias Bussonnier -
Show More
@@ -10,12 +10,13 b' This defines a callable class that IPython uses for `sys.displayhook`.'
10 from __future__ import print_function
10 from __future__ import print_function
11
11
12 import sys
12 import sys
13 import io, tokenize
13 import io as _io
14 import tokenize
14
15
15 from IPython.core.formatters import _safe_get_formatter_method
16 from IPython.core.formatters import _safe_get_formatter_method
16 from traitlets.config.configurable import Configurable
17 from traitlets.config.configurable import Configurable
17 from IPython.utils import io
18 from IPython.utils import io
18 from IPython.utils.py3compat import builtin_mod
19 from IPython.utils.py3compat import builtin_mod, cast_unicode_py2
19 from traitlets import Instance, Float
20 from traitlets import Instance, Float
20 from IPython.utils.warn import warn
21 from IPython.utils.warn import warn
21
22
@@ -84,22 +85,23 b' class DisplayHook(Configurable):'
84 def quiet(self):
85 def quiet(self):
85 """Should we silence the display hook because of ';'?"""
86 """Should we silence the display hook because of ';'?"""
86 # do not print output if input ends in ';'
87 # do not print output if input ends in ';'
87
88
88 cell = self.shell.history_manager.input_hist_parsed[self.prompt_count]
89 sio = io.StringIO(cell)
90 tokens = list(tokenize.generate_tokens(sio.readline))
91
92 try:
89 try:
93 for token in reversed(tokens):
90 cell = cast_unicode_py2(self.shell.history_manager.input_hist_parsed[-1])
94 if token.type in (tokenize.ENDMARKER, tokenize.COMMENT):
95 continue
96 if (token.type == tokenize.OP) and (token.string == ';'):
97 return True
98 else:
99 return False
100 except IndexError:
91 except IndexError:
101 # some uses of ipshellembed may fail here
92 # some uses of ipshellembed may fail here
102 return False
93 return False
94
95 sio = _io.StringIO(cell)
96 tokens = list(tokenize.generate_tokens(sio.readline))
97
98 for token in reversed(tokens):
99 if token[0] in (tokenize.ENDMARKER, tokenize.COMMENT):
100 continue
101 if (token[0] == tokenize.OP) and (token[1] == ';'):
102 return True
103 else:
104 return False
103
105
104 def start_displayhook(self):
106 def start_displayhook(self):
105 """Start the displayhook, initializing resources."""
107 """Start the displayhook, initializing resources."""
@@ -27,7 +27,7 b' def test_deepreload_numpy():'
27 # Standard exclusions:
27 # Standard exclusions:
28 'sys', 'os.path', builtin_mod_name, '__main__',
28 'sys', 'os.path', builtin_mod_name, '__main__',
29 # Test-related exclusions:
29 # Test-related exclusions:
30 'unittest', 'UserDict',
30 'unittest', 'UserDict', '_collections_abc', 'tokenize'
31 ]
31 ]
32
32
33 # `collections` builtin shall not be reloaded to avoid failure
33 # `collections` builtin shall not be reloaded to avoid failure
General Comments 0
You need to be logged in to leave comments. Login now