##// END OF EJS Templates
Merge branch 'master' of git://github.com/ipython/ipython into qtfrontend and fix conflicts in setupbase.py....
epatters -
r2664:6080a84e merge
parent child Browse files
Show More
@@ -0,0 +1,43 b''
1 """These kinds of tests are less than ideal, but at least they run.
2
3 This was an old test that was being run interactively in the top-level tests/
4 directory, which we are removing. For now putting this here ensures at least
5 we do run the test, though ultimately this functionality should all be tested
6 with better-isolated tests that don't rely on the global instance in iptest.
7 """
8
9 def doctest_autocall():
10 """
11 In [1]: def f1(a,b,c):
12 ...: return a+b+c
13 ...:
14
15 In [2]: def f2(a):
16 ...: return a + a
17 ...:
18
19 In [3]: ;f2 a b c
20 Out[3]: 'a b ca b c'
21
22 In [4]: assert _ == "a b ca b c"
23
24 In [5]: ,f1 a b c
25 Out[5]: 'abc'
26
27 In [6]: assert _ == 'abc'
28
29 In [7]: print _
30 abc
31
32 In [8]: /f1 1,2,3
33 Out[8]: 6
34
35 In [9]: assert _ == 6
36
37 In [10]: /f2 4
38 Out[10]: 8
39
40 In [11]: assert _ == 8
41
42 In [11]: del f1, f2
43 """
@@ -36,7 +36,7 b' from IPython.core.embed import InteractiveShellEmbed as IPShellEmbed'
36 36 def start(user_ns=None, embedded=False):
37 37 """Return an instance of :class:`InteractiveShell`."""
38 38 if embedded:
39 return InteractiveShellEmbed(user_ns=user_ns)
39 return IPShellEmbed(user_ns=user_ns)
40 40 else:
41 return InteractiveShell(user_ns=user_ns)
41 return IPShell(user_ns=user_ns)
42 42
@@ -115,12 +115,11 b' class CrashHandler(object):'
115 115
116 116 # Use this ONLY for developer debugging (keep commented out for release)
117 117 #color_scheme = 'Linux' # dbg
118
119 118 try:
120 119 rptdir = self.app.ipython_dir
121 120 except:
122 121 rptdir = os.getcwd()
123 if not os.path.isdir(rptdir):
122 if rptdir is None or not os.path.isdir(rptdir):
124 123 rptdir = os.getcwd()
125 124 report_name = os.path.join(rptdir,self.crash_report_fname)
126 125 # write the report filename into the instance dict so it can get
@@ -1126,32 +1126,40 b' Currently the magic system has the following functions:\\n"""'
1126 1126
1127 1127 Examples
1128 1128 --------
1129
1130 We first fully reset the namespace so your output looks identical to
1131 this example for pedagogical reasons; in practice you do not need a
1132 full reset.
1129 1133
1130 In [1]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8
1134 In [1]: %reset -f
1131 1135
1132 In [2]: who_ls
1133 Out[2]: ['a', 'b', 'b1', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c']
1136 Now, with a clean namespace we can make a few variables and use
1137 %reset_selective to only delete names that match our regexp:
1134 1138
1135 In [3]: %reset_selective -f b[2-3]m
1139 In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8
1136 1140
1137 In [4]: who_ls
1138 Out[4]: ['a', 'b', 'b1', 'b1m', 'b2s', 'c']
1141 In [3]: who_ls
1142 Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c']
1139 1143
1140 In [5]: %reset_selective -f d
1144 In [4]: %reset_selective -f b[2-3]m
1141 1145
1142 In [6]: who_ls
1143 Out[6]: ['a', 'b', 'b1', 'b1m', 'b2s', 'c']
1146 In [5]: who_ls
1147 Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c']
1144 1148
1145 In [7]: %reset_selective -f c
1146
1147 In [8]: who_ls
1148 Out[8]:['a', 'b', 'b1', 'b1m', 'b2s']
1149 In [6]: %reset_selective -f d
1149 1150
1150 In [9]: %reset_selective -f b
1151
1152 In [10]: who_ls
1153 Out[10]: ['a']
1154
1151 In [7]: who_ls
1152 Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c']
1153
1154 In [8]: %reset_selective -f c
1155
1156 In [9]: who_ls
1157 Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m']
1158
1159 In [10]: %reset_selective -f b
1160
1161 In [11]: who_ls
1162 Out[11]: ['a']
1155 1163 """
1156 1164
1157 1165 opts, regex = self.parse_options(parameter_s,'f')
@@ -995,7 +995,6 b' class HelpHandler(PrefilterHandler):'
995 995 # Pass any other exceptions through to the normal handler
996 996 return normal_handler.handle(line_info)
997 997 else:
998 raise
999 998 # If the code compiles ok, we should handle it normally
1000 999 return normal_handler.handle(line_info)
1001 1000
@@ -1,12 +1,41 b''
1 """Test the various handlers which do the actual rewriting of the line."""
1 """Tests for input handlers.
2 """
3 #-----------------------------------------------------------------------------
4 # Module imports
5 #-----------------------------------------------------------------------------
2 6
3 from StringIO import StringIO
4 import sys
5 sys.path.append('..')
7 # third party
8 import nose.tools as nt
9
10 # our own packages
11 from IPython.core import autocall
12 from IPython.testing import decorators as dec
13 from IPython.testing.globalipapp import get_ipython
14
15 #-----------------------------------------------------------------------------
16 # Globals
17 #-----------------------------------------------------------------------------
18
19 # Get the public instance of IPython
20 ip = get_ipython()
6 21
7 22 failures = []
8 23 num_tests = 0
9 24
25 #-----------------------------------------------------------------------------
26 # Test functions
27 #-----------------------------------------------------------------------------
28
29 class CallableIndexable(object):
30 def __getitem__(self, idx): return True
31 def __call__(self, *args, **kws): return True
32
33
34 class Autocallable(autocall.IPyAutocall):
35 def __call__(self):
36 return "called"
37
38
10 39 def run(tests):
11 40 """Loop through a list of (pre, post) inputs, where pre is the string
12 41 handed to ipython, and post is how that string looks after it's been
@@ -24,87 +53,56 b' def run(tests):'
24 53 pre, post, actual))
25 54
26 55
27 # Shutdown stdout/stderr so that ipython isn't noisy during tests. Have to
28 # do this *before* importing IPython below.
29 #
30 # NOTE: this means that, if you stick print statements into code as part of
31 # debugging, you won't see the results (unless you comment out some of the
32 # below). I keep on doing this, so apparently it's easy. Or I am an idiot.
33 old_stdout = sys.stdout
34 old_stderr = sys.stderr
35
36 sys.stdout = StringIO()
37 sys.stderr = StringIO()
38
39 import IPython
40 import IPython.ipapi
41
42 IPython.Shell.start()
43 ip = IPython.ipapi.get()
44
45 class CallableIndexable(object):
46 def __getitem__(self, idx): return True
47 def __call__(self, *args, **kws): return True
48
49
50 try:
56 def test_handlers():
51 57 # alias expansion
52
58
53 59 # We're using 'true' as our syscall of choice because it doesn't
54 60 # write anything to stdout.
55 61
56 62 # Turn off actual execution of aliases, because it's noisy
57 63 old_system_cmd = ip.system
58 64 ip.system = lambda cmd: None
59
60
61 ip.IP.alias_table['an_alias'] = (0, 'true')
65
66
67 ip.alias_manager.alias_table['an_alias'] = (0, 'true')
62 68 # These are useful for checking a particular recursive alias issue
63 ip.IP.alias_table['top'] = (0, 'd:/cygwin/top')
64 ip.IP.alias_table['d'] = (0, 'true')
65 run([("an_alias", '_ip.system("true ")'), # alias
69 ip.alias_manager.alias_table['top'] = (0, 'd:/cygwin/top')
70 ip.alias_manager.alias_table['d'] = (0, 'true')
71 run([("an_alias", 'get_ipython().system("true ")'), # alias
66 72 # Below: recursive aliases should expand whitespace-surrounded
67 73 # chars, *not* initial chars which happen to be aliases:
68 ("top", '_ip.system("d:/cygwin/top ")'),
74 ("top", 'get_ipython().system("d:/cygwin/top ")'),
69 75 ])
70 76 ip.system = old_system_cmd
71 77
72
73 78 call_idx = CallableIndexable()
74 ip.to_user_ns('call_idx')
79 ip.user_ns['call_idx'] = call_idx
75 80
76 81 # For many of the below, we're also checking that leading whitespace
77 82 # turns off the esc char, which it should unless there is a continuation
78 83 # line.
79 84 run([('"no change"', '"no change"'), # normal
80 ("!true", '_ip.system("true")'), # shell_escapes
81 ("!! true", '_ip.magic("sx true")'), # shell_escapes + magic
82 ("!!true", '_ip.magic("sx true")'), # shell_escapes + magic
83 ("%lsmagic", '_ip.magic("lsmagic ")'), # magic
84 ("lsmagic", '_ip.magic("lsmagic ")'), # magic
85 ("a = b # PYTHON-MODE", '_i'), # emacs -- avoids _in cache
85 ("!true", 'get_ipython().system("true")'), # shell_escapes
86 ("!! true", 'get_ipython().magic("sx true")'), # shell_escapes + magic
87 ("!!true", 'get_ipython().magic("sx true")'), # shell_escapes + magic
88 ("%lsmagic", 'get_ipython().magic("lsmagic ")'), # magic
89 ("lsmagic", 'get_ipython().magic("lsmagic ")'), # magic
90 #("a = b # PYTHON-MODE", '_i'), # emacs -- avoids _in cache
86 91
87 92 # post-esc-char whitespace goes inside
88 ("! true", '_ip.system(" true")'),
89
90 # Leading whitespace generally turns off escape characters
91 (" ! true", ' ! true'),
92 (" !true", ' !true'),
93 ("! true", 'get_ipython().system(" true")'),
93 94
94 95 # handle_help
95 96
96 97 # These are weak tests -- just looking at what the help handlers
97 98 # logs, which is not how it really does its work. But it still
98 99 # lets us check the key paths through the handler.
99
100
100 101 ("x=1 # what?", "x=1 # what?"), # no help if valid python
101 ("len?", "#?len"), # this is what help logs when it runs
102 ("len??", "#?len?"),
103 ("?len", "#?len"),
104 102 ])
105 103
106 104 # multi_line_specials
107 ip.options.multi_line_specials = 0
105 ip.prefilter_manager.multi_line_specials = False
108 106 # W/ multi_line_specials off, leading ws kills esc chars/autoexpansion
109 107 run([
110 108 ('if 1:\n !true', 'if 1:\n !true'),
@@ -112,18 +110,16 b' try:'
112 110 ('if 1:\n an_alias', 'if 1:\n an_alias'),
113 111 ])
114 112
115 ip.options.multi_line_specials = 1
113 ip.prefilter_manager.multi_line_specials = True
116 114 # initial indents must be preserved.
117 115 run([
118 ('if 1:\n !true', 'if 1:\n _ip.system("true")'),
119 ('if 1:\n lsmagic', 'if 1:\n _ip.magic("lsmagic ")'),
120 ('if 1:\n an_alias', 'if 1:\n _ip.system("true ")'),
116 ('if 1:\n !true', 'if 1:\n get_ipython().system("true")'),
117 ('if 2:\n lsmagic', 'if 2:\n get_ipython().magic("lsmagic ")'),
118 ('if 1:\n an_alias', 'if 1:\n get_ipython().system("true ")'),
121 119 # Weird one
122 ('if 1:\n !!true', 'if 1:\n _ip.magic("sx true")'),
123
120 ('if 1:\n !!true', 'if 1:\n get_ipython().magic("sx true")'),
124 121
125 # Even with m_l_s on, all esc_chars except ! are off
126 ('if 1:\n %lsmagic', 'if 1:\n %lsmagic'),
122 # Even with m_l_s on, autocall is off even with special chars
127 123 ('if 1:\n /fun 1 2', 'if 1:\n /fun 1 2'),
128 124 ('if 1:\n ;fun 1 2', 'if 1:\n ;fun 1 2'),
129 125 ('if 1:\n ,fun 1 2', 'if 1:\n ,fun 1 2'),
@@ -131,18 +127,12 b' try:'
131 127 # What about !!
132 128 ])
133 129
134
135 130 # Objects which are instances of IPyAutocall are *always* autocalled
136 import IPython.ipapi
137 class Autocallable(IPython.ipapi.IPyAutocall):
138 def __call__(self):
139 return "called"
140
141 131 autocallable = Autocallable()
142 ip.to_user_ns('autocallable')
132 ip.user_ns['autocallable'] = autocallable
143 133
144 134 # auto
145 ip.options.autocall = 0
135 ip.magic('autocall 0')
146 136 # Only explicit escapes or instances of IPyAutocallable should get
147 137 # expanded
148 138 run([
@@ -152,7 +142,7 b' try:'
152 142 (";list 1 2 3", 'list("1 2 3")'),
153 143 ("/len range(1,4)", 'len(range(1,4))'),
154 144 ])
155 ip.options.autocall = 1
145 ip.magic('autocall 1')
156 146 run([
157 147 (",list 1 2 3", 'list("1", "2", "3")'),
158 148 (";list 1 2 3", 'list("1 2 3")'),
@@ -166,8 +156,7 b' try:'
166 156 ('call_idx 1', 'call_idx(1)'),
167 157 ('len', 'len '), # only at 2 does it auto-call on single args
168 158 ])
169
170 ip.options.autocall = 2
159 ip.magic('autocall 2')
171 160 run([
172 161 (",list 1 2 3", 'list("1", "2", "3")'),
173 162 (";list 1 2 3", 'list("1 2 3")'),
@@ -180,23 +169,6 b' try:'
180 169 # This is what's different:
181 170 ('len', 'len()'), # only at 2 does it auto-call on single args
182 171 ])
183 ip.options.autocall = 1
184
185 # Ignoring handle_emacs, 'cause it doesn't do anything.
186 finally:
187 sys.stdout = old_stdout
188 sys.stderr = old_stderr
189
190
191
192
193 num_f = len(failures)
194 #if verbose:
195 # print
196
172 ip.magic('autocall 1')
197 173
198 print "%s tests run, %s failure%s" % (num_tests,
199 num_f,
200 num_f != 1 and "s" or "")
201 for f in failures:
202 print f
174 nt.assert_equals(failures, [])
@@ -243,3 +243,37 b' SystemExit Traceback (most recent call last)'
243 243 <BLANKLINE>
244 244 SystemExit: (2, 'Mode = exit')
245 245 """
246
247
248 def test_runlines():
249 import textwrap
250 ip.runlines(['a = 10', 'a+=1'])
251 ip.runlines('assert a == 11\nassert 1')
252
253 nt.assert_equals(ip.user_ns['a'], 11)
254 complex = textwrap.dedent("""
255 if 1:
256 print "hello"
257 if 1:
258 print "world"
259
260 if 2:
261 print "foo"
262
263 if 3:
264 print "bar"
265
266 if 4:
267 print "bar"
268
269 """)
270 # Simply verifies that this kind of input is run
271 ip.runlines(complex)
272
273
274 def test_db():
275 """Test the internal database used for variable persistence."""
276 ip.db['__unittest_'] = 12
277 nt.assert_equals(ip.db['__unittest_'], 12)
278 del ip.db['__unittest_']
279 assert '__unittest_' not in ip.db
@@ -267,8 +267,91 b' def doctest_time():'
267 267 Wall time: 0.00 s
268 268 """
269 269
270
270 271 def test_doctest_mode():
271 272 "Toggle doctest_mode twice, it should be a no-op and run without error"
272 273 _ip.magic('doctest_mode')
273 274 _ip.magic('doctest_mode')
275
276
277 def test_parse_options():
278 """Tests for basic options parsing in magics."""
279 # These are only the most minimal of tests, more should be added later. At
280 # the very least we check that basic text/unicode calls work OK.
281 nt.assert_equal(_ip.parse_options('foo', '')[1], 'foo')
282 nt.assert_equal(_ip.parse_options(u'foo', '')[1], u'foo')
283
284
285 def test_dirops():
286 """Test various directory handling operations."""
287 curpath = lambda :os.path.splitdrive(os.getcwd())[1].replace('\\','/')
288
289 startdir = os.getcwd()
290 ipdir = _ip.ipython_dir
291 try:
292 _ip.magic('cd "%s"' % ipdir)
293 nt.assert_equal(curpath(), ipdir)
294 _ip.magic('cd -')
295 nt.assert_equal(curpath(), startdir)
296 _ip.magic('pushd "%s"' % ipdir)
297 nt.assert_equal(curpath(), ipdir)
298 _ip.magic('popd')
299 nt.assert_equal(curpath(), startdir)
300 finally:
301 os.chdir(startdir)
302
303
304 def check_cpaste(code, should_fail=False):
305 """Execute code via 'cpaste' and ensure it was executed, unless
306 should_fail is set.
307 """
308 _ip.user_ns['code_ran'] = False
309
310 src = StringIO()
311 src.write('\n')
312 src.write(code)
313 src.write('\n--\n')
314 src.seek(0)
315
316 stdin_save = sys.stdin
317 sys.stdin = src
274 318
319 try:
320 _ip.magic('cpaste')
321 except:
322 if not should_fail:
323 raise AssertionError("Failure not expected : '%s'" %
324 code)
325 else:
326 assert _ip.user_ns['code_ran']
327 if should_fail:
328 raise AssertionError("Failure expected : '%s'" % code)
329 finally:
330 sys.stdin = stdin_save
331
332
333 def test_cpaste():
334 """Test cpaste magic"""
335
336 def run():
337 """Marker function: sets a flag when executed.
338 """
339 _ip.user_ns['code_ran'] = True
340 return 'run' # return string so '+ run()' doesn't result in success
341
342 tests = {'pass': ["> > > run()",
343 ">>> > run()",
344 "+++ run()",
345 "++ run()",
346 " >>> run()"],
347
348 'fail': ["+ + run()",
349 " ++ run()"]}
350
351 _ip.user_ns['run'] = run
352
353 for code in tests['pass']:
354 check_cpaste(code)
355
356 for code in tests['fail']:
357 check_cpaste(code, should_fail=True)
@@ -53,7 +53,16 b' def test_autocall_binops():'
53 53 def test_issue114():
54 54 """Check that multiline string literals don't expand as magic
55 55 see http://github.com/ipython/ipython/issues/#issue/114"""
56
56 57 template = '"""\n%s\n"""'
57 for mgk in ip.lsmagic():
58 raw = template % mgk
59 yield nt.assert_equals(ip.prefilter(raw), raw)
58 # Store the current value of multi_line_specials and turn it off before
59 # running test, since it could be true (case in which the test doesn't make
60 # sense, as multiline string literals *will* expand as magic in that case).
61 msp = ip.prefilter_manager.multi_line_specials
62 ip.prefilter_manager.multi_line_specials = False
63 try:
64 for mgk in ip.lsmagic():
65 raw = template % mgk
66 yield nt.assert_equals(ip.prefilter(raw), raw)
67 finally:
68 ip.prefilter_manager.multi_line_specials = msp
1 NO CONTENT: file renamed from IPython/frontend/cocoa/__init__.py to IPython/deathrow/gui/__init__.py
1 NO CONTENT: file renamed from IPython/frontend/cocoa/tests/__init__.py to IPython/deathrow/gui/wx/__init__.py
1 NO CONTENT: file renamed from IPython/gui/wx/ipshell_nonblocking.py to IPython/deathrow/gui/wx/ipshell_nonblocking.py
1 NO CONTENT: file renamed from IPython/gui/wx/ipython_history.py to IPython/deathrow/gui/wx/ipython_history.py
1 NO CONTENT: file renamed from IPython/gui/wx/ipython_view.py to IPython/deathrow/gui/wx/ipython_view.py
1 NO CONTENT: file renamed from IPython/gui/wx/thread_ex.py to IPython/deathrow/gui/wx/thread_ex.py
1 NO CONTENT: file renamed from IPython/gui/wx/wxIPython.py to IPython/deathrow/gui/wx/wxIPython.py
1 NO CONTENT: file renamed from IPython/frontend/asyncfrontendbase.py to IPython/deathrow/oldfrontend/asyncfrontendbase.py
1 NO CONTENT: file renamed from IPython/frontend/tests/__init__.py to IPython/deathrow/oldfrontend/cocoa/__init__.py
1 NO CONTENT: file renamed from IPython/frontend/cocoa/cocoa_frontend.py to IPython/deathrow/oldfrontend/cocoa/cocoa_frontend.py
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/English.lproj/InfoPlist.strings to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/English.lproj/InfoPlist.strings
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/English.lproj/MainMenu.xib to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/English.lproj/MainMenu.xib
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/IPython1Sandbox.xcodeproj/project.pbxproj to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/IPython1Sandbox.xcodeproj/project.pbxproj
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/IPython1SandboxAppDelegate.py to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/IPython1SandboxAppDelegate.py
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/IPython1Sandbox_Prefix.pch to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/IPython1Sandbox_Prefix.pch
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/IPythonCocoaController Tests-Info.plist to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/IPythonCocoaController Tests-Info.plist
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/Info.plist to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/Info.plist
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/main.m to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/main.m
1 NO CONTENT: file renamed from IPython/frontend/cocoa/examples/IPython1Sandbox/main.py to IPython/deathrow/oldfrontend/cocoa/examples/IPython1Sandbox/main.py
1 NO CONTENT: file renamed from IPython/frontend/cocoa/plugin/CocoaFrontendPlugin.xcodeproj/project.pbxproj to IPython/deathrow/oldfrontend/cocoa/plugin/CocoaFrontendPlugin.xcodeproj/project.pbxproj
1 NO CONTENT: file renamed from IPython/frontend/cocoa/plugin/IPythonCocoaFrontendLoader.py to IPython/deathrow/oldfrontend/cocoa/plugin/IPythonCocoaFrontendLoader.py
1 NO CONTENT: file renamed from IPython/frontend/cocoa/plugin/Makefile to IPython/deathrow/oldfrontend/cocoa/plugin/Makefile
1 NO CONTENT: file renamed from IPython/frontend/cocoa/plugin/Placeholder (Do Not Use)-Info.plist to IPython/deathrow/oldfrontend/cocoa/plugin/Placeholder (Do Not Use)-Info.plist
1 NO CONTENT: file renamed from IPython/frontend/cocoa/plugin/plugins.mk to IPython/deathrow/oldfrontend/cocoa/plugin/plugins.mk
1 NO CONTENT: file renamed from IPython/frontend/cocoa/plugin/setup.py to IPython/deathrow/oldfrontend/cocoa/plugin/setup.py
1 NO CONTENT: file renamed from IPython/frontend/wx/__init__.py to IPython/deathrow/oldfrontend/cocoa/tests/__init__.py
1 NO CONTENT: file renamed from IPython/frontend/cocoa/tests/test_cocoa_frontend.py to IPython/deathrow/oldfrontend/cocoa/tests/test_cocoa_frontend.py
1 NO CONTENT: file renamed from IPython/frontend/frontendbase.py to IPython/deathrow/oldfrontend/frontendbase.py
1 NO CONTENT: file renamed from IPython/frontend/linefrontendbase.py to IPython/deathrow/oldfrontend/linefrontendbase.py
1 NO CONTENT: file renamed from IPython/frontend/prefilterfrontend.py to IPython/deathrow/oldfrontend/prefilterfrontend.py
1 NO CONTENT: file renamed from IPython/frontend/process/__init__.py to IPython/deathrow/oldfrontend/process/__init__.py
1 NO CONTENT: file renamed from IPython/frontend/process/killableprocess.py to IPython/deathrow/oldfrontend/process/killableprocess.py
1 NO CONTENT: file renamed from IPython/frontend/process/pipedprocess.py to IPython/deathrow/oldfrontend/process/pipedprocess.py
1 NO CONTENT: file renamed from IPython/frontend/process/winprocess.py to IPython/deathrow/oldfrontend/process/winprocess.py
1 NO CONTENT: file renamed from IPython/gui/__init__.py to IPython/deathrow/oldfrontend/tests/__init__.py
1 NO CONTENT: file renamed from IPython/frontend/tests/test_asyncfrontendbase.py to IPython/deathrow/oldfrontend/tests/test_asyncfrontendbase.py
1 NO CONTENT: file renamed from IPython/frontend/tests/test_frontendbase.py to IPython/deathrow/oldfrontend/tests/test_frontendbase.py
1 NO CONTENT: file renamed from IPython/frontend/tests/test_linefrontend.py to IPython/deathrow/oldfrontend/tests/test_linefrontend.py
1 NO CONTENT: file renamed from IPython/frontend/tests/test_prefilterfrontend.py to IPython/deathrow/oldfrontend/tests/test_prefilterfrontend.py
1 NO CONTENT: file renamed from IPython/frontend/tests/test_process.py to IPython/deathrow/oldfrontend/tests/test_process.py
1 NO CONTENT: file renamed from IPython/gui/wx/__init__.py to IPython/deathrow/oldfrontend/wx/__init__.py
1 NO CONTENT: file renamed from IPython/frontend/wx/console_widget.py to IPython/deathrow/oldfrontend/wx/console_widget.py
1 NO CONTENT: file renamed from IPython/frontend/wx/ipythonx.py to IPython/deathrow/oldfrontend/wx/ipythonx.py
1 NO CONTENT: file renamed from IPython/frontend/wx/wx_frontend.py to IPython/deathrow/oldfrontend/wx/wx_frontend.py
1 NO CONTENT: file renamed from IPython/frontend/zopeinterface.py to IPython/deathrow/oldfrontend/zopeinterface.py
1 NO CONTENT: file renamed from test/test_prefilter.py to IPython/deathrow/tests/test_prefilter.py
@@ -306,8 +306,8 b' class IPythonRunner(InteractiveRunner):'
306 306 args0 = ['--colors','NoColor',
307 307 '-pi1','In [\\#]: ',
308 308 '-pi2',' .\\D.: ',
309 '--noterm-title',
310 '--no-auto-indent']
309 '--no-term-title',
310 '--no-autoindent']
311 311 if args is None: args = args0
312 312 else: args = args0 + args
313 313 prompts = [r'In \[\d+\]: ',r' \.*: ']
@@ -1,4 +1,3 b''
1 #!/usr/bin/env python
2 1 """Test suite for the irunner module.
3 2
4 3 Not the most elegant or fine-grained, but it does cover at least the bulk
@@ -13,7 +12,7 b' import sys'
13 12 import unittest
14 13
15 14 # IPython imports
16 from IPython import irunner
15 from IPython.lib import irunner
17 16
18 17 # Testing code begins
19 18 class RunnerTestCase(unittest.TestCase):
@@ -29,12 +28,12 b' class RunnerTestCase(unittest.TestCase):'
29 28 out = self.out.getvalue()
30 29 #out = ''
31 30 # this output contains nasty \r\n lineends, and the initial ipython
32 # banner. clean it up for comparison
33 output_l = output.split()
34 out_l = out.split()
31 # banner. clean it up for comparison, removing lines of whitespace
32 output_l = [l for l in output.splitlines() if l and not l.isspace()]
33 out_l = [l for l in out.splitlines() if l and not l.isspace()]
35 34 mismatch = 0
36 #if len(output_l) != len(out_l):
37 # self.fail('mismatch in number of lines')
35 if len(output_l) != len(out_l):
36 self.fail('mismatch in number of lines')
38 37 for n in range(len(output_l)):
39 38 # Do a line-by-line comparison
40 39 ol1 = output_l[n].strip()
@@ -53,7 +52,6 b' class RunnerTestCase(unittest.TestCase):'
53 52 """Test the IPython runner."""
54 53 source = """
55 54 print 'hello, this is python'
56
57 55 # some more code
58 56 x=1;y=2
59 57 x+y**2
@@ -99,11 +97,10 b' In [7]: autocall 0'
99 97 Automatic calling is: OFF
100 98
101 99 In [8]: cos pi
102 ------------------------------------------------------------
103 100 File "<ipython console>", line 1
104 101 cos pi
105 102 ^
106 <type 'exceptions.SyntaxError'>: invalid syntax
103 SyntaxError: invalid syntax
107 104
108 105
109 106 In [9]: cos(pi)
@@ -163,6 +160,3 b' hello, this is python'
163 160 that's all folks!
164 161 """
165 162 self._test_runner(runner,source,output)
166
167 if __name__ == '__main__':
168 unittest.main()
@@ -104,7 +104,6 b" have['wx.aui'] = test_for('wx.aui')"
104 104 have['zope.interface'] = test_for('zope.interface')
105 105 have['twisted'] = test_for('twisted')
106 106 have['foolscap'] = test_for('foolscap')
107 have['objc'] = test_for('objc')
108 107 have['pexpect'] = test_for('pexpect')
109 108 have['gtk'] = test_for('gtk')
110 109 have['gobject'] = test_for('gobject')
@@ -154,7 +153,6 b' def make_exclude():'
154 153 ipjoin = lambda *paths: pjoin('IPython', *paths)
155 154
156 155 exclusions = [ipjoin('external'),
157 ipjoin('frontend', 'process', 'winprocess.py'),
158 156 # Deprecated old Shell and iplib modules, skip to avoid
159 157 # warnings
160 158 ipjoin('Shell'),
@@ -175,19 +173,11 b' def make_exclude():'
175 173 ]
176 174
177 175 if not have['wx']:
178 exclusions.append(ipjoin('gui'))
179 exclusions.append(ipjoin('frontend', 'wx'))
180 176 exclusions.append(ipjoin('lib', 'inputhookwx'))
181 177
182 178 if not have['gtk'] or not have['gobject']:
183 179 exclusions.append(ipjoin('lib', 'inputhookgtk'))
184 180
185 if not have['wx.aui']:
186 exclusions.append(ipjoin('gui', 'wx', 'wxIPython'))
187
188 if not have['objc']:
189 exclusions.append(ipjoin('frontend', 'cocoa'))
190
191 181 # These have to be skipped on win32 because the use echo, rm, cd, etc.
192 182 # See ticket https://bugs.launchpad.net/bugs/366982
193 183 if sys.platform == 'win32':
@@ -203,15 +193,7 b' def make_exclude():'
203 193 # how we are isolating dependencies in testing.
204 194 if not (have['twisted'] and have['zope.interface'] and have['foolscap']):
205 195 exclusions.extend(
206 [ipjoin('frontend', 'asyncfrontendbase'),
207 ipjoin('frontend', 'prefilterfrontend'),
208 ipjoin('frontend', 'frontendbase'),
209 ipjoin('frontend', 'linefrontendbase'),
210 ipjoin('frontend', 'tests', 'test_linefrontend'),
211 ipjoin('frontend', 'tests', 'test_frontendbase'),
212 ipjoin('frontend', 'tests', 'test_prefilterfrontend'),
213 ipjoin('frontend', 'tests', 'test_asyncfrontendbase'),
214 ipjoin('testing', 'parametric'),
196 [ipjoin('testing', 'parametric'),
215 197 ipjoin('testing', 'util'),
216 198 ipjoin('testing', 'tests', 'test_decorators_trial'),
217 199 ] )
@@ -317,9 +299,6 b' def make_runners():'
317 299 # The machinery in kernel needs twisted for real testing
318 300 trial_pkg_names = []
319 301
320 if have['wx']:
321 nose_pkg_names.append('gui')
322
323 302 # And add twisted ones if conditions are met
324 303 if have['zope.interface'] and have['twisted'] and have['foolscap']:
325 304 # We only list IPython.kernel for testing using twisted.trial as
@@ -136,13 +136,12 b' def arg_split(s, posix=False):'
136 136 function, but with a default of posix=False for splitting, so that quotes
137 137 in inputs are respected."""
138 138
139 # XXX - there may be unicode-related problems here!!! I'm not sure that
140 # shlex is truly unicode-safe, so it might be necessary to do
141 #
142 # s = s.encode(sys.stdin.encoding)
143 #
144 # first, to ensure that shlex gets a normal string. Input from anyone who
145 # knows more about unicode and shlex than I would be good to have here...
139 # Unfortunately, python's shlex module is buggy with unicode input:
140 # http://bugs.python.org/issue1170
141 # At least encoding the input when it's unicode seems to help, but there
142 # may be more problems lurking. Apparently this is fixed in python3.
143 if isinstance(s, unicode):
144 s = s.encode(sys.stdin.encoding)
146 145 lex = shlex.shlex(s, posix=posix)
147 146 lex.whitespace_split = True
148 147 return list(lex)
@@ -18,7 +18,7 b' import sys'
18 18
19 19 import nose.tools as nt
20 20
21 from IPython.utils.process import find_cmd, FindCmdError
21 from IPython.utils.process import find_cmd, FindCmdError, arg_split
22 22 from IPython.testing import decorators as dec
23 23
24 24 #-----------------------------------------------------------------------------
@@ -59,4 +59,10 b' def test_find_cmd_fail():'
59 59 nt.assert_raises(FindCmdError,find_cmd,'asdfasdf')
60 60
61 61
62
62 def test_arg_split():
63 """Ensure that argument lines are correctly split like in a shell."""
64 tests = [['hi', ['hi']],
65 [u'hi', [u'hi']],
66 ]
67 for argstr, argv in tests:
68 nt.assert_equal(arg_split(argstr), argv)
@@ -1,38 +1,52 b''
1 # -*- coding: UTF-8 -*-
2 import sys, unittest
3 sys.path.append ('..')
1 """Some tests for the wildcard utilities."""
4 2
5 from IPython import wildcard
3 #-----------------------------------------------------------------------------
4 # Library imports
5 #-----------------------------------------------------------------------------
6 # Stdlib
7 import sys
8 import unittest
9
10 # Our own
11 from IPython.utils import wildcard
12
13 #-----------------------------------------------------------------------------
14 # Globals for test
15 #-----------------------------------------------------------------------------
6 16
7 17 class obj_t(object):
8 18 pass
9 19
10 root=obj_t()
11 l=["arna","abel","ABEL","active","bob","bark","abbot"]
12 q=["kate","loop","arne","vito","lucifer","koppel"]
20 root = obj_t()
21 l = ["arna","abel","ABEL","active","bob","bark","abbot"]
22 q = ["kate","loop","arne","vito","lucifer","koppel"]
13 23 for x in l:
14 o=obj_t()
24 o = obj_t()
15 25 setattr(root,x,o)
16 26 for y in q:
17 p=obj_t()
27 p = obj_t()
18 28 setattr(o,y,p)
19 root._apan=obj_t()
20 root._apan.a=10
21 root._apan._a=20
22 root._apan.__a=20
23 root.__anka=obj_t()
24 root.__anka.a=10
25 root.__anka._a=20
26 root.__anka.__a=20
29 root._apan = obj_t()
30 root._apan.a = 10
31 root._apan._a = 20
32 root._apan.__a = 20
33 root.__anka = obj_t()
34 root.__anka.a = 10
35 root.__anka._a = 20
36 root.__anka.__a = 20
37
38 root._APAN = obj_t()
39 root._APAN.a = 10
40 root._APAN._a = 20
41 root._APAN.__a = 20
42 root.__ANKA = obj_t()
43 root.__ANKA.a = 10
44 root.__ANKA._a = 20
45 root.__ANKA.__a = 20
27 46
28 root._APAN=obj_t()
29 root._APAN.a=10
30 root._APAN._a=20
31 root._APAN.__a=20
32 root.__ANKA=obj_t()
33 root.__ANKA.a=10
34 root.__ANKA._a=20
35 root.__ANKA.__a=20
47 #-----------------------------------------------------------------------------
48 # Test cases
49 #-----------------------------------------------------------------------------
36 50
37 51 class Tests (unittest.TestCase):
38 52 def test_case(self):
@@ -46,7 +60,8 b' class Tests (unittest.TestCase):'
46 60 ]
47 61 for pat,res in tests:
48 62 res.sort()
49 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=False).keys()
63 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,
64 show_all=False).keys()
50 65 a.sort()
51 66 self.assertEqual(a,res)
52 67
@@ -61,7 +76,8 b' class Tests (unittest.TestCase):'
61 76 ]
62 77 for pat,res in tests:
63 78 res.sort()
64 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,show_all=True).keys()
79 a=wildcard.list_namespace(ns,"all",pat,ignore_case=False,
80 show_all=True).keys()
65 81 a.sort()
66 82 self.assertEqual(a,res)
67 83
@@ -70,14 +86,16 b' class Tests (unittest.TestCase):'
70 86 ns=root.__dict__
71 87 tests=[
72 88 ("a*", ["abbot","abel","ABEL","active","arna",]),
73 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]),
89 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",
90 "ABEL.koppel","ABEL.loop",]),
74 91 ("_a*", []),
75 92 ("_*anka", ["__anka","__ANKA",]),
76 93 ("_*a*", ["__anka","__ANKA",]),
77 94 ]
78 95 for pat,res in tests:
79 96 res.sort()
80 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=False).keys()
97 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,
98 show_all=False).keys()
81 99 a.sort()
82 100 self.assertEqual(a,res)
83 101
@@ -85,16 +103,15 b' class Tests (unittest.TestCase):'
85 103 ns=root.__dict__
86 104 tests=[
87 105 ("a*", ["abbot","abel","ABEL","active","arna",]),
88 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop","ABEL.koppel","ABEL.loop",]),
106 ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop",
107 "ABEL.koppel","ABEL.loop",]),
89 108 ("_a*", ["_apan","_APAN"]),
90 109 ("_*anka", ["__anka","__ANKA",]),
91 110 ("_*a*", ["__anka","__ANKA","_apan","_APAN"]),
92 111 ]
93 112 for pat,res in tests:
94 113 res.sort()
95 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,show_all=True).keys()
114 a=wildcard.list_namespace(ns,"all",pat,ignore_case=True,
115 show_all=True).keys()
96 116 a.sort()
97 117 self.assertEqual(a,res)
98
99 if __name__ == '__main__':
100 unittest.main() No newline at end of file
@@ -108,19 +108,9 b' def find_packages():'
108 108 add_package(packages, 'deathrow', tests=True)
109 109 add_package(packages, 'extensions')
110 110 add_package(packages, 'external')
111 add_package(packages, 'frontend', tests=True)
112 # Don't include the cocoa frontend for now as it is not stable
113 if sys.platform == 'darwin' and False:
114 add_package(packages, 'frontend.cocoa', tests=True, others=['plugin'])
115 add_package(packages, 'frontend.cocoa.examples')
116 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox')
117 add_package(packages, 'frontend.cocoa.examples.IPython1Sandbox.English.lproj')
118 add_package(packages, 'frontend.process')
111 add_package(packages, 'frontend')
119 112 add_package(packages, 'frontend.qt')
120 113 add_package(packages, 'frontend.qt.console')
121 add_package(packages, 'frontend.wx')
122 add_package(packages, 'gui')
123 add_package(packages, 'gui.wx')
124 114 add_package(packages, 'kernel', config=False, tests=True, scripts=True)
125 115 add_package(packages, 'kernel.core', config=False, tests=True)
126 116 add_package(packages, 'lib', tests=True)
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now