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