Show More
@@ -269,7 +269,7 b' def magic_run_completer(self, event):' | |||||
269 | # should complete on all files, since after the first one other files may |
|
269 | # should complete on all files, since after the first one other files may | |
270 | # be arguments to the input script. |
|
270 | # be arguments to the input script. | |
271 |
|
271 | |||
272 |
if |
|
272 | if any(magic_run_re.match(c) for c in comps): | |
273 | pys = [f.replace('\\','/') for f in lglob('*')] |
|
273 | pys = [f.replace('\\','/') for f in lglob('*')] | |
274 | else: |
|
274 | else: | |
275 | pys = [f.replace('\\','/') |
|
275 | pys = [f.replace('\\','/') |
@@ -146,7 +146,10 b' class Tracer(object):' | |||||
146 | # at least raise that limit to 80 chars, which should be enough for |
|
146 | # at least raise that limit to 80 chars, which should be enough for | |
147 | # most interactive uses. |
|
147 | # most interactive uses. | |
148 | try: |
|
148 | try: | |
149 | from reprlib import aRepr |
|
149 | try: | |
|
150 | from reprlib import aRepr # Py 3 | |||
|
151 | except ImportError: | |||
|
152 | from repr import aRepr # Py 2 | |||
150 | aRepr.maxstring = 80 |
|
153 | aRepr.maxstring = 80 | |
151 | except: |
|
154 | except: | |
152 | # This is only a user-facing convenience, so any error we encounter |
|
155 | # This is only a user-facing convenience, so any error we encounter | |
@@ -331,7 +334,10 b' class Pdb(OldPdb):' | |||||
331 | # vds: << |
|
334 | # vds: << | |
332 |
|
335 | |||
333 | def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3): |
|
336 | def format_stack_entry(self, frame_lineno, lprefix=': ', context = 3): | |
334 | import reprlib |
|
337 | try: | |
|
338 | import reprlib # Py 3 | |||
|
339 | except ImportError: | |||
|
340 | import repr as reprlib # Py 2 | |||
335 |
|
341 | |||
336 | ret = [] |
|
342 | ret = [] | |
337 |
|
343 |
@@ -401,8 +401,6 b' class NamespaceMagics(Magics):' | |||||
401 | ndarray_type = ndarray.__name__ |
|
401 | ndarray_type = ndarray.__name__ | |
402 |
|
402 | |||
403 | # Find all variable names and types so we can figure out column sizes |
|
403 | # Find all variable names and types so we can figure out column sizes | |
404 | def get_vars(i): |
|
|||
405 | return self.shell.user_ns[i] |
|
|||
406 |
|
404 | |||
407 | # some types are well known and can be shorter |
|
405 | # some types are well known and can be shorter | |
408 | abbrevs = {'IPython.core.macro.Macro' : 'Macro'} |
|
406 | abbrevs = {'IPython.core.macro.Macro' : 'Macro'} | |
@@ -410,7 +408,7 b' class NamespaceMagics(Magics):' | |||||
410 | tn = type(v).__name__ |
|
408 | tn = type(v).__name__ | |
411 | return abbrevs.get(tn,tn) |
|
409 | return abbrevs.get(tn,tn) | |
412 |
|
410 | |||
413 | varlist = map(get_vars,varnames) |
|
411 | varlist = [self.shell.user_ns[n] for n in varnames] | |
414 |
|
412 | |||
415 | typelist = [] |
|
413 | typelist = [] | |
416 | for vv in varlist: |
|
414 | for vv in varlist: | |
@@ -583,7 +581,7 b' class NamespaceMagics(Magics):' | |||||
583 | from numpy import ndarray |
|
581 | from numpy import ndarray | |
584 | # This must be done with items and not iteritems because |
|
582 | # This must be done with items and not iteritems because | |
585 | # we're going to modify the dict in-place. |
|
583 | # we're going to modify the dict in-place. | |
586 | for x,val in user_ns.items(): |
|
584 | for x,val in list(user_ns.items()): | |
587 | if isinstance(val,ndarray): |
|
585 | if isinstance(val,ndarray): | |
588 | del user_ns[x] |
|
586 | del user_ns[x] | |
589 | except ImportError: |
|
587 | except ImportError: |
@@ -65,7 +65,7 b' def check_line_split(splitter, test_specs):' | |||||
65 |
|
65 | |||
66 |
|
66 | |||
67 | def test_line_split(): |
|
67 | def test_line_split(): | |
68 |
"""Basic |
|
68 | """Basic line splitter test with default specs.""" | |
69 | sp = completer.CompletionSplitter() |
|
69 | sp = completer.CompletionSplitter() | |
70 | # The format of the test specs is: part1, part2, expected answer. Parts 1 |
|
70 | # The format of the test specs is: part1, part2, expected answer. Parts 1 | |
71 | # and 2 are joined into the 'line' sent to the splitter, as if the cursor |
|
71 | # and 2 are joined into the 'line' sent to the splitter, as if the cursor | |
@@ -105,7 +105,7 b' def test_unicode_completions():' | |||||
105 | # Some strings that trigger different types of completion. Check them both |
|
105 | # Some strings that trigger different types of completion. Check them both | |
106 | # in str and unicode forms |
|
106 | # in str and unicode forms | |
107 | s = ['ru', '%ru', 'cd /', 'floa', 'float(x)/'] |
|
107 | s = ['ru', '%ru', 'cd /', 'floa', 'float(x)/'] | |
108 | for t in s + map(unicode_type, s): |
|
108 | for t in s + list(map(unicode_type, s)): | |
109 | # We don't need to check exact completion values (they may change |
|
109 | # We don't need to check exact completion values (they may change | |
110 | # depending on the state of the namespace, but at least no exceptions |
|
110 | # depending on the state of the namespace, but at least no exceptions | |
111 | # should be thrown and the return value should be a pair of text, list |
|
111 | # should be thrown and the return value should be a pair of text, list | |
@@ -159,7 +159,7 b' def test_abspath_file_completions():' | |||||
159 | ip = get_ipython() |
|
159 | ip = get_ipython() | |
160 | with TemporaryDirectory() as tmpdir: |
|
160 | with TemporaryDirectory() as tmpdir: | |
161 | prefix = os.path.join(tmpdir, 'foo') |
|
161 | prefix = os.path.join(tmpdir, 'foo') | |
162 |
suffixes = |
|
162 | suffixes = ['1', '2'] | |
163 | names = [prefix+s for s in suffixes] |
|
163 | names = [prefix+s for s in suffixes] | |
164 | for n in names: |
|
164 | for n in names: | |
165 | open(n, 'w').close() |
|
165 | open(n, 'w').close() | |
@@ -182,7 +182,7 b' def test_local_file_completions():' | |||||
182 | with TemporaryDirectory() as tmpdir: |
|
182 | with TemporaryDirectory() as tmpdir: | |
183 | os.chdir(tmpdir) |
|
183 | os.chdir(tmpdir) | |
184 | prefix = './foo' |
|
184 | prefix = './foo' | |
185 |
suffixes = |
|
185 | suffixes = ['1', '2'] | |
186 | names = [prefix+s for s in suffixes] |
|
186 | names = [prefix+s for s in suffixes] | |
187 | for n in names: |
|
187 | for n in names: | |
188 | open(n, 'w').close() |
|
188 | open(n, 'w').close() | |
@@ -206,7 +206,7 b' def test_greedy_completions():' | |||||
206 | greedy_original = ip.Completer.greedy |
|
206 | greedy_original = ip.Completer.greedy | |
207 | try: |
|
207 | try: | |
208 | ip.Completer.greedy = False |
|
208 | ip.Completer.greedy = False | |
209 | ip.ex('a=range(5)') |
|
209 | ip.ex('a=list(range(5))') | |
210 | _,c = ip.complete('.',line='a[0].') |
|
210 | _,c = ip.complete('.',line='a[0].') | |
211 | nt.assert_false('a[0].real' in c, |
|
211 | nt.assert_false('a[0].real' in c, | |
212 | "Shouldn't have completed on a[0]: %s"%c) |
|
212 | "Shouldn't have completed on a[0]: %s"%c) | |
@@ -227,18 +227,18 b' def test_omit__names():' | |||||
227 | cfg.IPCompleter.omit__names = 0 |
|
227 | cfg.IPCompleter.omit__names = 0 | |
228 | c.update_config(cfg) |
|
228 | c.update_config(cfg) | |
229 | s,matches = c.complete('ip.') |
|
229 | s,matches = c.complete('ip.') | |
230 |
nt.assert_ |
|
230 | nt.assert_in('ip.__str__', matches) | |
231 |
nt.assert_ |
|
231 | nt.assert_in('ip._hidden_attr', matches) | |
232 | cfg.IPCompleter.omit__names = 1 |
|
232 | cfg.IPCompleter.omit__names = 1 | |
233 | c.update_config(cfg) |
|
233 | c.update_config(cfg) | |
234 | s,matches = c.complete('ip.') |
|
234 | s,matches = c.complete('ip.') | |
235 |
nt.assert_ |
|
235 | nt.assert_not_in('ip.__str__', matches) | |
236 |
nt.assert_ |
|
236 | nt.assert_in('ip._hidden_attr', matches) | |
237 | cfg.IPCompleter.omit__names = 2 |
|
237 | cfg.IPCompleter.omit__names = 2 | |
238 | c.update_config(cfg) |
|
238 | c.update_config(cfg) | |
239 | s,matches = c.complete('ip.') |
|
239 | s,matches = c.complete('ip.') | |
240 |
nt.assert_ |
|
240 | nt.assert_not_in('ip.__str__', matches) | |
241 |
nt.assert_ |
|
241 | nt.assert_not_in('ip._hidden_attr', matches) | |
242 | del ip._hidden_attr |
|
242 | del ip._hidden_attr | |
243 |
|
243 | |||
244 |
|
244 | |||
@@ -251,7 +251,7 b' def test_limit_to__all__False_ok():' | |||||
251 | cfg.IPCompleter.limit_to__all__ = False |
|
251 | cfg.IPCompleter.limit_to__all__ = False | |
252 | c.update_config(cfg) |
|
252 | c.update_config(cfg) | |
253 | s, matches = c.complete('d.') |
|
253 | s, matches = c.complete('d.') | |
254 |
nt.assert_ |
|
254 | nt.assert_in('d.x', matches) | |
255 |
|
255 | |||
256 |
|
256 | |||
257 | def test_limit_to__all__True_ok(): |
|
257 | def test_limit_to__all__True_ok(): | |
@@ -264,8 +264,8 b' def test_limit_to__all__True_ok():' | |||||
264 | cfg.IPCompleter.limit_to__all__ = True |
|
264 | cfg.IPCompleter.limit_to__all__ = True | |
265 | c.update_config(cfg) |
|
265 | c.update_config(cfg) | |
266 | s, matches = c.complete('d.') |
|
266 | s, matches = c.complete('d.') | |
267 |
nt.assert_ |
|
267 | nt.assert_in('d.z', matches) | |
268 |
nt.assert_ |
|
268 | nt.assert_not_in('d.x', matches) | |
269 |
|
269 | |||
270 |
|
270 | |||
271 | def test_get__all__entries_ok(): |
|
271 | def test_get__all__entries_ok(): |
@@ -58,7 +58,10 b' class PdbTestInput(object):' | |||||
58 | #----------------------------------------------------------------------------- |
|
58 | #----------------------------------------------------------------------------- | |
59 |
|
59 | |||
60 | def test_longer_repr(): |
|
60 | def test_longer_repr(): | |
61 | from reprlib import repr as trepr |
|
61 | try: | |
|
62 | from reprlib import repr as trepr # Py 3 | |||
|
63 | except ImportError: | |||
|
64 | from repr import repr as trepr # Py 2 | |||
62 |
|
65 | |||
63 | a = '1234567890'* 7 |
|
66 | a = '1234567890'* 7 | |
64 | ar = "'1234567890123456789012345678901234567890123456789012345678901234567890'" |
|
67 | ar = "'1234567890123456789012345678901234567890123456789012345678901234567890'" |
@@ -9,12 +9,17 b' from __future__ import absolute_import' | |||||
9 | #----------------------------------------------------------------------------- |
|
9 | #----------------------------------------------------------------------------- | |
10 |
|
10 | |||
11 | import sys |
|
11 | import sys | |
12 | from io import StringIO |
|
|||
13 | from unittest import TestCase |
|
12 | from unittest import TestCase | |
14 |
|
13 | |||
15 | import nose.tools as nt |
|
14 | import nose.tools as nt | |
16 |
|
15 | |||
17 | from IPython.testing import tools as tt |
|
16 | from IPython.testing import tools as tt | |
|
17 | from IPython.utils.py3compat import PY3 | |||
|
18 | ||||
|
19 | if PY3: | |||
|
20 | from io import StringIO | |||
|
21 | else: | |||
|
22 | from StringIO import StringIO | |||
18 |
|
23 | |||
19 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
20 | # Globals |
|
25 | # Globals |
General Comments 0
You need to be logged in to leave comments.
Login now