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 | def start(user_ns=None, embedded=False): |
|
36 | def start(user_ns=None, embedded=False): | |
37 | """Return an instance of :class:`InteractiveShell`.""" |
|
37 | """Return an instance of :class:`InteractiveShell`.""" | |
38 | if embedded: |
|
38 | if embedded: | |
39 |
return I |
|
39 | return IPShellEmbed(user_ns=user_ns) | |
40 | else: |
|
40 | else: | |
41 |
return I |
|
41 | return IPShell(user_ns=user_ns) | |
42 |
|
42 |
@@ -115,12 +115,11 b' class CrashHandler(object):' | |||||
115 |
|
115 | |||
116 | # Use this ONLY for developer debugging (keep commented out for release) |
|
116 | # Use this ONLY for developer debugging (keep commented out for release) | |
117 | #color_scheme = 'Linux' # dbg |
|
117 | #color_scheme = 'Linux' # dbg | |
118 |
|
||||
119 | try: |
|
118 | try: | |
120 | rptdir = self.app.ipython_dir |
|
119 | rptdir = self.app.ipython_dir | |
121 | except: |
|
120 | except: | |
122 | rptdir = os.getcwd() |
|
121 | rptdir = os.getcwd() | |
123 | if not os.path.isdir(rptdir): |
|
122 | if rptdir is None or not os.path.isdir(rptdir): | |
124 | rptdir = os.getcwd() |
|
123 | rptdir = os.getcwd() | |
125 | report_name = os.path.join(rptdir,self.crash_report_fname) |
|
124 | report_name = os.path.join(rptdir,self.crash_report_fname) | |
126 | # write the report filename into the instance dict so it can get |
|
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 | Examples |
|
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 |
|
1136 | Now, with a clean namespace we can make a few variables and use | |
1133 | Out[2]: ['a', 'b', 'b1', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c'] |
|
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 [ |
|
1141 | In [3]: who_ls | |
1138 |
Out[ |
|
1142 | Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c'] | |
1139 |
|
1143 | |||
1140 |
In [ |
|
1144 | In [4]: %reset_selective -f b[2-3]m | |
1141 |
|
1145 | |||
1142 |
In [ |
|
1146 | In [5]: who_ls | |
1143 |
Out[ |
|
1147 | Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] | |
1144 |
|
1148 | |||
1145 |
In [ |
|
1149 | In [6]: %reset_selective -f d | |
1146 |
|
||||
1147 | In [8]: who_ls |
|
|||
1148 | Out[8]:['a', 'b', 'b1', 'b1m', 'b2s'] |
|
|||
1149 |
|
1150 | |||
1150 | In [9]: %reset_selective -f b |
|
1151 | In [7]: who_ls | |
1151 |
|
1152 | Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] | ||
1152 | In [10]: who_ls |
|
1153 | ||
1153 | Out[10]: ['a'] |
|
1154 | In [8]: %reset_selective -f c | |
1154 |
|
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 | opts, regex = self.parse_options(parameter_s,'f') |
|
1165 | opts, regex = self.parse_options(parameter_s,'f') |
@@ -995,7 +995,6 b' class HelpHandler(PrefilterHandler):' | |||||
995 | # Pass any other exceptions through to the normal handler |
|
995 | # Pass any other exceptions through to the normal handler | |
996 | return normal_handler.handle(line_info) |
|
996 | return normal_handler.handle(line_info) | |
997 | else: |
|
997 | else: | |
998 | raise |
|
|||
999 | # If the code compiles ok, we should handle it normally |
|
998 | # If the code compiles ok, we should handle it normally | |
1000 | return normal_handler.handle(line_info) |
|
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 |
|
7 | # third party | |
4 | import sys |
|
8 | import nose.tools as nt | |
5 | sys.path.append('..') |
|
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 | failures = [] |
|
22 | failures = [] | |
8 | num_tests = 0 |
|
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 | def run(tests): |
|
39 | def run(tests): | |
11 | """Loop through a list of (pre, post) inputs, where pre is the string |
|
40 | """Loop through a list of (pre, post) inputs, where pre is the string | |
12 | handed to ipython, and post is how that string looks after it's been |
|
41 | handed to ipython, and post is how that string looks after it's been | |
@@ -24,87 +53,56 b' def run(tests):' | |||||
24 | pre, post, actual)) |
|
53 | pre, post, actual)) | |
25 |
|
54 | |||
26 |
|
55 | |||
27 | # Shutdown stdout/stderr so that ipython isn't noisy during tests. Have to |
|
56 | def test_handlers(): | |
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: |
|
|||
51 | # alias expansion |
|
57 | # alias expansion | |
52 |
|
58 | |||
53 | # We're using 'true' as our syscall of choice because it doesn't |
|
59 | # We're using 'true' as our syscall of choice because it doesn't | |
54 | # write anything to stdout. |
|
60 | # write anything to stdout. | |
55 |
|
61 | |||
56 | # Turn off actual execution of aliases, because it's noisy |
|
62 | # Turn off actual execution of aliases, because it's noisy | |
57 | old_system_cmd = ip.system |
|
63 | old_system_cmd = ip.system | |
58 | ip.system = lambda cmd: None |
|
64 | ip.system = lambda cmd: None | |
59 |
|
65 | |||
60 |
|
66 | |||
61 |
ip. |
|
67 | ip.alias_manager.alias_table['an_alias'] = (0, 'true') | |
62 | # These are useful for checking a particular recursive alias issue |
|
68 | # These are useful for checking a particular recursive alias issue | |
63 |
ip. |
|
69 | ip.alias_manager.alias_table['top'] = (0, 'd:/cygwin/top') | |
64 |
ip. |
|
70 | ip.alias_manager.alias_table['d'] = (0, 'true') | |
65 | run([("an_alias", '_ip.system("true ")'), # alias |
|
71 | run([("an_alias", 'get_ipython().system("true ")'), # alias | |
66 | # Below: recursive aliases should expand whitespace-surrounded |
|
72 | # Below: recursive aliases should expand whitespace-surrounded | |
67 | # chars, *not* initial chars which happen to be aliases: |
|
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 | ip.system = old_system_cmd |
|
76 | ip.system = old_system_cmd | |
71 |
|
77 | |||
72 |
|
||||
73 | call_idx = CallableIndexable() |
|
78 | call_idx = CallableIndexable() | |
74 |
ip. |
|
79 | ip.user_ns['call_idx'] = call_idx | |
75 |
|
80 | |||
76 | # For many of the below, we're also checking that leading whitespace |
|
81 | # For many of the below, we're also checking that leading whitespace | |
77 | # turns off the esc char, which it should unless there is a continuation |
|
82 | # turns off the esc char, which it should unless there is a continuation | |
78 | # line. |
|
83 | # line. | |
79 | run([('"no change"', '"no change"'), # normal |
|
84 | run([('"no change"', '"no change"'), # normal | |
80 | ("!true", '_ip.system("true")'), # shell_escapes |
|
85 | ("!true", 'get_ipython().system("true")'), # shell_escapes | |
81 | ("!! true", '_ip.magic("sx true")'), # shell_escapes + magic |
|
86 | ("!! true", 'get_ipython().magic("sx true")'), # shell_escapes + magic | |
82 | ("!!true", '_ip.magic("sx true")'), # shell_escapes + magic |
|
87 | ("!!true", 'get_ipython().magic("sx true")'), # shell_escapes + magic | |
83 | ("%lsmagic", '_ip.magic("lsmagic ")'), # magic |
|
88 | ("%lsmagic", 'get_ipython().magic("lsmagic ")'), # magic | |
84 | ("lsmagic", '_ip.magic("lsmagic ")'), # magic |
|
89 | ("lsmagic", 'get_ipython().magic("lsmagic ")'), # magic | |
85 | ("a = b # PYTHON-MODE", '_i'), # emacs -- avoids _in cache |
|
90 | #("a = b # PYTHON-MODE", '_i'), # emacs -- avoids _in cache | |
86 |
|
91 | |||
87 | # post-esc-char whitespace goes inside |
|
92 | # post-esc-char whitespace goes inside | |
88 | ("! true", '_ip.system(" true")'), |
|
93 | ("! true", 'get_ipython().system(" true")'), | |
89 |
|
||||
90 | # Leading whitespace generally turns off escape characters |
|
|||
91 | (" ! true", ' ! true'), |
|
|||
92 | (" !true", ' !true'), |
|
|||
93 |
|
94 | |||
94 | # handle_help |
|
95 | # handle_help | |
95 |
|
96 | |||
96 | # These are weak tests -- just looking at what the help handlers |
|
97 | # These are weak tests -- just looking at what the help handlers | |
97 | # logs, which is not how it really does its work. But it still |
|
98 | # logs, which is not how it really does its work. But it still | |
98 | # lets us check the key paths through the handler. |
|
99 | # lets us check the key paths through the handler. | |
99 |
|
100 | |||
100 | ("x=1 # what?", "x=1 # what?"), # no help if valid python |
|
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 | # multi_line_specials |
|
104 | # multi_line_specials | |
107 |
ip. |
|
105 | ip.prefilter_manager.multi_line_specials = False | |
108 | # W/ multi_line_specials off, leading ws kills esc chars/autoexpansion |
|
106 | # W/ multi_line_specials off, leading ws kills esc chars/autoexpansion | |
109 | run([ |
|
107 | run([ | |
110 | ('if 1:\n !true', 'if 1:\n !true'), |
|
108 | ('if 1:\n !true', 'if 1:\n !true'), | |
@@ -112,18 +110,16 b' try:' | |||||
112 | ('if 1:\n an_alias', 'if 1:\n an_alias'), |
|
110 | ('if 1:\n an_alias', 'if 1:\n an_alias'), | |
113 | ]) |
|
111 | ]) | |
114 |
|
112 | |||
115 |
ip. |
|
113 | ip.prefilter_manager.multi_line_specials = True | |
116 | # initial indents must be preserved. |
|
114 | # initial indents must be preserved. | |
117 | run([ |
|
115 | run([ | |
118 | ('if 1:\n !true', 'if 1:\n _ip.system("true")'), |
|
116 | ('if 1:\n !true', 'if 1:\n get_ipython().system("true")'), | |
119 |
('if |
|
117 | ('if 2:\n lsmagic', 'if 2:\n get_ipython().magic("lsmagic ")'), | |
120 | ('if 1:\n an_alias', 'if 1:\n _ip.system("true ")'), |
|
118 | ('if 1:\n an_alias', 'if 1:\n get_ipython().system("true ")'), | |
121 | # Weird one |
|
119 | # Weird one | |
122 | ('if 1:\n !!true', 'if 1:\n _ip.magic("sx true")'), |
|
120 | ('if 1:\n !!true', 'if 1:\n get_ipython().magic("sx true")'), | |
123 |
|
||||
124 |
|
121 | |||
125 |
# Even with m_l_s on, a |
|
122 | # Even with m_l_s on, autocall is off even with special chars | |
126 | ('if 1:\n %lsmagic', 'if 1:\n %lsmagic'), |
|
|||
127 | ('if 1:\n /fun 1 2', 'if 1:\n /fun 1 2'), |
|
123 | ('if 1:\n /fun 1 2', 'if 1:\n /fun 1 2'), | |
128 | ('if 1:\n ;fun 1 2', 'if 1:\n ;fun 1 2'), |
|
124 | ('if 1:\n ;fun 1 2', 'if 1:\n ;fun 1 2'), | |
129 | ('if 1:\n ,fun 1 2', 'if 1:\n ,fun 1 2'), |
|
125 | ('if 1:\n ,fun 1 2', 'if 1:\n ,fun 1 2'), | |
@@ -131,18 +127,12 b' try:' | |||||
131 | # What about !! |
|
127 | # What about !! | |
132 | ]) |
|
128 | ]) | |
133 |
|
129 | |||
134 |
|
||||
135 | # Objects which are instances of IPyAutocall are *always* autocalled |
|
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 | autocallable = Autocallable() |
|
131 | autocallable = Autocallable() | |
142 |
ip. |
|
132 | ip.user_ns['autocallable'] = autocallable | |
143 |
|
133 | |||
144 | # auto |
|
134 | # auto | |
145 |
ip. |
|
135 | ip.magic('autocall 0') | |
146 | # Only explicit escapes or instances of IPyAutocallable should get |
|
136 | # Only explicit escapes or instances of IPyAutocallable should get | |
147 | # expanded |
|
137 | # expanded | |
148 | run([ |
|
138 | run([ | |
@@ -152,7 +142,7 b' try:' | |||||
152 | (";list 1 2 3", 'list("1 2 3")'), |
|
142 | (";list 1 2 3", 'list("1 2 3")'), | |
153 | ("/len range(1,4)", 'len(range(1,4))'), |
|
143 | ("/len range(1,4)", 'len(range(1,4))'), | |
154 | ]) |
|
144 | ]) | |
155 |
ip. |
|
145 | ip.magic('autocall 1') | |
156 | run([ |
|
146 | run([ | |
157 | (",list 1 2 3", 'list("1", "2", "3")'), |
|
147 | (",list 1 2 3", 'list("1", "2", "3")'), | |
158 | (";list 1 2 3", 'list("1 2 3")'), |
|
148 | (";list 1 2 3", 'list("1 2 3")'), | |
@@ -166,8 +156,7 b' try:' | |||||
166 | ('call_idx 1', 'call_idx(1)'), |
|
156 | ('call_idx 1', 'call_idx(1)'), | |
167 | ('len', 'len '), # only at 2 does it auto-call on single args |
|
157 | ('len', 'len '), # only at 2 does it auto-call on single args | |
168 | ]) |
|
158 | ]) | |
169 |
|
159 | ip.magic('autocall 2') | ||
170 | ip.options.autocall = 2 |
|
|||
171 | run([ |
|
160 | run([ | |
172 | (",list 1 2 3", 'list("1", "2", "3")'), |
|
161 | (",list 1 2 3", 'list("1", "2", "3")'), | |
173 | (";list 1 2 3", 'list("1 2 3")'), |
|
162 | (";list 1 2 3", 'list("1 2 3")'), | |
@@ -180,23 +169,6 b' try:' | |||||
180 | # This is what's different: |
|
169 | # This is what's different: | |
181 | ('len', 'len()'), # only at 2 does it auto-call on single args |
|
170 | ('len', 'len()'), # only at 2 does it auto-call on single args | |
182 | ]) |
|
171 | ]) | |
183 |
ip. |
|
172 | ip.magic('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 |
|
||||
196 |
|
||||
197 |
|
173 | |||
198 | print "%s tests run, %s failure%s" % (num_tests, |
|
174 | nt.assert_equals(failures, []) | |
199 | num_f, |
|
|||
200 | num_f != 1 and "s" or "") |
|
|||
201 | for f in failures: |
|
|||
202 | print f |
|
@@ -243,3 +243,37 b' SystemExit Traceback (most recent call last)' | |||||
243 | <BLANKLINE> |
|
243 | <BLANKLINE> | |
244 | SystemExit: (2, 'Mode = exit') |
|
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 | Wall time: 0.00 s |
|
267 | Wall time: 0.00 s | |
268 | """ |
|
268 | """ | |
269 |
|
269 | |||
|
270 | ||||
270 | def test_doctest_mode(): |
|
271 | def test_doctest_mode(): | |
271 | "Toggle doctest_mode twice, it should be a no-op and run without error" |
|
272 | "Toggle doctest_mode twice, it should be a no-op and run without error" | |
272 | _ip.magic('doctest_mode') |
|
273 | _ip.magic('doctest_mode') | |
273 | _ip.magic('doctest_mode') |
|
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 | def test_issue114(): |
|
53 | def test_issue114(): | |
54 | """Check that multiline string literals don't expand as magic |
|
54 | """Check that multiline string literals don't expand as magic | |
55 | see http://github.com/ipython/ipython/issues/#issue/114""" |
|
55 | see http://github.com/ipython/ipython/issues/#issue/114""" | |
|
56 | ||||
56 | template = '"""\n%s\n"""' |
|
57 | template = '"""\n%s\n"""' | |
57 | for mgk in ip.lsmagic(): |
|
58 | # Store the current value of multi_line_specials and turn it off before | |
58 | raw = template % mgk |
|
59 | # running test, since it could be true (case in which the test doesn't make | |
59 | yield nt.assert_equals(ip.prefilter(raw), raw) |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 | args0 = ['--colors','NoColor', |
|
306 | args0 = ['--colors','NoColor', | |
307 | '-pi1','In [\\#]: ', |
|
307 | '-pi1','In [\\#]: ', | |
308 | '-pi2',' .\\D.: ', |
|
308 | '-pi2',' .\\D.: ', | |
309 | '--noterm-title', |
|
309 | '--no-term-title', | |
310 |
'--no-auto |
|
310 | '--no-autoindent'] | |
311 | if args is None: args = args0 |
|
311 | if args is None: args = args0 | |
312 | else: args = args0 + args |
|
312 | else: args = args0 + args | |
313 | prompts = [r'In \[\d+\]: ',r' \.*: '] |
|
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 | Not the most elegant or fine-grained, but it does cover at least the bulk |
|
3 | Not the most elegant or fine-grained, but it does cover at least the bulk | |
@@ -13,7 +12,7 b' import sys' | |||||
13 | import unittest |
|
12 | import unittest | |
14 |
|
13 | |||
15 | # IPython imports |
|
14 | # IPython imports | |
16 | from IPython import irunner |
|
15 | from IPython.lib import irunner | |
17 |
|
16 | |||
18 | # Testing code begins |
|
17 | # Testing code begins | |
19 | class RunnerTestCase(unittest.TestCase): |
|
18 | class RunnerTestCase(unittest.TestCase): | |
@@ -29,12 +28,12 b' class RunnerTestCase(unittest.TestCase):' | |||||
29 | out = self.out.getvalue() |
|
28 | out = self.out.getvalue() | |
30 | #out = '' |
|
29 | #out = '' | |
31 | # this output contains nasty \r\n lineends, and the initial ipython |
|
30 | # this output contains nasty \r\n lineends, and the initial ipython | |
32 | # banner. clean it up for comparison |
|
31 | # banner. clean it up for comparison, removing lines of whitespace | |
33 | output_l = output.split() |
|
32 | output_l = [l for l in output.splitlines() if l and not l.isspace()] | |
34 | out_l = out.split() |
|
33 | out_l = [l for l in out.splitlines() if l and not l.isspace()] | |
35 | mismatch = 0 |
|
34 | mismatch = 0 | |
36 |
|
|
35 | if len(output_l) != len(out_l): | |
37 |
|
|
36 | self.fail('mismatch in number of lines') | |
38 | for n in range(len(output_l)): |
|
37 | for n in range(len(output_l)): | |
39 | # Do a line-by-line comparison |
|
38 | # Do a line-by-line comparison | |
40 | ol1 = output_l[n].strip() |
|
39 | ol1 = output_l[n].strip() | |
@@ -53,7 +52,6 b' class RunnerTestCase(unittest.TestCase):' | |||||
53 | """Test the IPython runner.""" |
|
52 | """Test the IPython runner.""" | |
54 | source = """ |
|
53 | source = """ | |
55 | print 'hello, this is python' |
|
54 | print 'hello, this is python' | |
56 |
|
||||
57 | # some more code |
|
55 | # some more code | |
58 | x=1;y=2 |
|
56 | x=1;y=2 | |
59 | x+y**2 |
|
57 | x+y**2 | |
@@ -99,11 +97,10 b' In [7]: autocall 0' | |||||
99 | Automatic calling is: OFF |
|
97 | Automatic calling is: OFF | |
100 |
|
98 | |||
101 | In [8]: cos pi |
|
99 | In [8]: cos pi | |
102 | ------------------------------------------------------------ |
|
|||
103 | File "<ipython console>", line 1 |
|
100 | File "<ipython console>", line 1 | |
104 | cos pi |
|
101 | cos pi | |
105 | ^ |
|
102 | ^ | |
106 |
|
|
103 | SyntaxError: invalid syntax | |
107 |
|
104 | |||
108 |
|
105 | |||
109 | In [9]: cos(pi) |
|
106 | In [9]: cos(pi) | |
@@ -163,6 +160,3 b' hello, this is python' | |||||
163 | that's all folks! |
|
160 | that's all folks! | |
164 | """ |
|
161 | """ | |
165 | self._test_runner(runner,source,output) |
|
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 | have['zope.interface'] = test_for('zope.interface') |
|
104 | have['zope.interface'] = test_for('zope.interface') | |
105 | have['twisted'] = test_for('twisted') |
|
105 | have['twisted'] = test_for('twisted') | |
106 | have['foolscap'] = test_for('foolscap') |
|
106 | have['foolscap'] = test_for('foolscap') | |
107 | have['objc'] = test_for('objc') |
|
|||
108 | have['pexpect'] = test_for('pexpect') |
|
107 | have['pexpect'] = test_for('pexpect') | |
109 | have['gtk'] = test_for('gtk') |
|
108 | have['gtk'] = test_for('gtk') | |
110 | have['gobject'] = test_for('gobject') |
|
109 | have['gobject'] = test_for('gobject') | |
@@ -154,7 +153,6 b' def make_exclude():' | |||||
154 | ipjoin = lambda *paths: pjoin('IPython', *paths) |
|
153 | ipjoin = lambda *paths: pjoin('IPython', *paths) | |
155 |
|
154 | |||
156 | exclusions = [ipjoin('external'), |
|
155 | exclusions = [ipjoin('external'), | |
157 | ipjoin('frontend', 'process', 'winprocess.py'), |
|
|||
158 | # Deprecated old Shell and iplib modules, skip to avoid |
|
156 | # Deprecated old Shell and iplib modules, skip to avoid | |
159 | # warnings |
|
157 | # warnings | |
160 | ipjoin('Shell'), |
|
158 | ipjoin('Shell'), | |
@@ -175,19 +173,11 b' def make_exclude():' | |||||
175 | ] |
|
173 | ] | |
176 |
|
174 | |||
177 | if not have['wx']: |
|
175 | if not have['wx']: | |
178 | exclusions.append(ipjoin('gui')) |
|
|||
179 | exclusions.append(ipjoin('frontend', 'wx')) |
|
|||
180 | exclusions.append(ipjoin('lib', 'inputhookwx')) |
|
176 | exclusions.append(ipjoin('lib', 'inputhookwx')) | |
181 |
|
177 | |||
182 | if not have['gtk'] or not have['gobject']: |
|
178 | if not have['gtk'] or not have['gobject']: | |
183 | exclusions.append(ipjoin('lib', 'inputhookgtk')) |
|
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 | # These have to be skipped on win32 because the use echo, rm, cd, etc. |
|
181 | # These have to be skipped on win32 because the use echo, rm, cd, etc. | |
192 | # See ticket https://bugs.launchpad.net/bugs/366982 |
|
182 | # See ticket https://bugs.launchpad.net/bugs/366982 | |
193 | if sys.platform == 'win32': |
|
183 | if sys.platform == 'win32': | |
@@ -203,15 +193,7 b' def make_exclude():' | |||||
203 | # how we are isolating dependencies in testing. |
|
193 | # how we are isolating dependencies in testing. | |
204 | if not (have['twisted'] and have['zope.interface'] and have['foolscap']): |
|
194 | if not (have['twisted'] and have['zope.interface'] and have['foolscap']): | |
205 | exclusions.extend( |
|
195 | exclusions.extend( | |
206 |
[ipjoin(' |
|
196 | [ipjoin('testing', 'parametric'), | |
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'), |
|
|||
215 | ipjoin('testing', 'util'), |
|
197 | ipjoin('testing', 'util'), | |
216 | ipjoin('testing', 'tests', 'test_decorators_trial'), |
|
198 | ipjoin('testing', 'tests', 'test_decorators_trial'), | |
217 | ] ) |
|
199 | ] ) | |
@@ -317,9 +299,6 b' def make_runners():' | |||||
317 | # The machinery in kernel needs twisted for real testing |
|
299 | # The machinery in kernel needs twisted for real testing | |
318 | trial_pkg_names = [] |
|
300 | trial_pkg_names = [] | |
319 |
|
301 | |||
320 | if have['wx']: |
|
|||
321 | nose_pkg_names.append('gui') |
|
|||
322 |
|
||||
323 | # And add twisted ones if conditions are met |
|
302 | # And add twisted ones if conditions are met | |
324 | if have['zope.interface'] and have['twisted'] and have['foolscap']: |
|
303 | if have['zope.interface'] and have['twisted'] and have['foolscap']: | |
325 | # We only list IPython.kernel for testing using twisted.trial as |
|
304 | # We only list IPython.kernel for testing using twisted.trial as |
@@ -136,13 +136,12 b' def arg_split(s, posix=False):' | |||||
136 | function, but with a default of posix=False for splitting, so that quotes |
|
136 | function, but with a default of posix=False for splitting, so that quotes | |
137 | in inputs are respected.""" |
|
137 | in inputs are respected.""" | |
138 |
|
138 | |||
139 | # XXX - there may be unicode-related problems here!!! I'm not sure that |
|
139 | # Unfortunately, python's shlex module is buggy with unicode input: | |
140 | # shlex is truly unicode-safe, so it might be necessary to do |
|
140 | # http://bugs.python.org/issue1170 | |
141 | # |
|
141 | # At least encoding the input when it's unicode seems to help, but there | |
142 | # s = s.encode(sys.stdin.encoding) |
|
142 | # may be more problems lurking. Apparently this is fixed in python3. | |
143 | # |
|
143 | if isinstance(s, unicode): | |
144 | # first, to ensure that shlex gets a normal string. Input from anyone who |
|
144 | s = s.encode(sys.stdin.encoding) | |
145 | # knows more about unicode and shlex than I would be good to have here... |
|
|||
146 | lex = shlex.shlex(s, posix=posix) |
|
145 | lex = shlex.shlex(s, posix=posix) | |
147 | lex.whitespace_split = True |
|
146 | lex.whitespace_split = True | |
148 | return list(lex) |
|
147 | return list(lex) |
@@ -18,7 +18,7 b' import sys' | |||||
18 |
|
18 | |||
19 | import nose.tools as nt |
|
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 | from IPython.testing import decorators as dec |
|
22 | from IPython.testing import decorators as dec | |
23 |
|
23 | |||
24 | #----------------------------------------------------------------------------- |
|
24 | #----------------------------------------------------------------------------- | |
@@ -59,4 +59,10 b' def test_find_cmd_fail():' | |||||
59 | nt.assert_raises(FindCmdError,find_cmd,'asdfasdf') |
|
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 -*- |
|
1 | """Some tests for the wildcard utilities.""" | |
2 | import sys, unittest |
|
|||
3 | sys.path.append ('..') |
|
|||
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 | class obj_t(object): |
|
17 | class obj_t(object): | |
8 | pass |
|
18 | pass | |
9 |
|
19 | |||
10 | root=obj_t() |
|
20 | root = obj_t() | |
11 | l=["arna","abel","ABEL","active","bob","bark","abbot"] |
|
21 | l = ["arna","abel","ABEL","active","bob","bark","abbot"] | |
12 | q=["kate","loop","arne","vito","lucifer","koppel"] |
|
22 | q = ["kate","loop","arne","vito","lucifer","koppel"] | |
13 | for x in l: |
|
23 | for x in l: | |
14 | o=obj_t() |
|
24 | o = obj_t() | |
15 | setattr(root,x,o) |
|
25 | setattr(root,x,o) | |
16 | for y in q: |
|
26 | for y in q: | |
17 | p=obj_t() |
|
27 | p = obj_t() | |
18 | setattr(o,y,p) |
|
28 | setattr(o,y,p) | |
19 | root._apan=obj_t() |
|
29 | root._apan = obj_t() | |
20 | root._apan.a=10 |
|
30 | root._apan.a = 10 | |
21 | root._apan._a=20 |
|
31 | root._apan._a = 20 | |
22 | root._apan.__a=20 |
|
32 | root._apan.__a = 20 | |
23 | root.__anka=obj_t() |
|
33 | root.__anka = obj_t() | |
24 | root.__anka.a=10 |
|
34 | root.__anka.a = 10 | |
25 | root.__anka._a=20 |
|
35 | root.__anka._a = 20 | |
26 | 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() |
|
47 | #----------------------------------------------------------------------------- | |
29 | root._APAN.a=10 |
|
48 | # Test cases | |
30 | root._APAN._a=20 |
|
49 | #----------------------------------------------------------------------------- | |
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 |
|
|||
36 |
|
50 | |||
37 | class Tests (unittest.TestCase): |
|
51 | class Tests (unittest.TestCase): | |
38 | def test_case(self): |
|
52 | def test_case(self): | |
@@ -46,7 +60,8 b' class Tests (unittest.TestCase):' | |||||
46 | ] |
|
60 | ] | |
47 | for pat,res in tests: |
|
61 | for pat,res in tests: | |
48 | res.sort() |
|
62 | res.sort() | |
49 |
a=wildcard.list_namespace(ns,"all",pat,ignore_case=False, |
|
63 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=False, | |
|
64 | show_all=False).keys() | |||
50 | a.sort() |
|
65 | a.sort() | |
51 | self.assertEqual(a,res) |
|
66 | self.assertEqual(a,res) | |
52 |
|
67 | |||
@@ -61,7 +76,8 b' class Tests (unittest.TestCase):' | |||||
61 | ] |
|
76 | ] | |
62 | for pat,res in tests: |
|
77 | for pat,res in tests: | |
63 | res.sort() |
|
78 | res.sort() | |
64 |
a=wildcard.list_namespace(ns,"all",pat,ignore_case=False, |
|
79 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=False, | |
|
80 | show_all=True).keys() | |||
65 | a.sort() |
|
81 | a.sort() | |
66 | self.assertEqual(a,res) |
|
82 | self.assertEqual(a,res) | |
67 |
|
83 | |||
@@ -70,14 +86,16 b' class Tests (unittest.TestCase):' | |||||
70 | ns=root.__dict__ |
|
86 | ns=root.__dict__ | |
71 | tests=[ |
|
87 | tests=[ | |
72 | ("a*", ["abbot","abel","ABEL","active","arna",]), |
|
88 | ("a*", ["abbot","abel","ABEL","active","arna",]), | |
73 |
("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop", |
|
89 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop", | |
|
90 | "ABEL.koppel","ABEL.loop",]), | |||
74 | ("_a*", []), |
|
91 | ("_a*", []), | |
75 | ("_*anka", ["__anka","__ANKA",]), |
|
92 | ("_*anka", ["__anka","__ANKA",]), | |
76 | ("_*a*", ["__anka","__ANKA",]), |
|
93 | ("_*a*", ["__anka","__ANKA",]), | |
77 | ] |
|
94 | ] | |
78 | for pat,res in tests: |
|
95 | for pat,res in tests: | |
79 | res.sort() |
|
96 | res.sort() | |
80 |
a=wildcard.list_namespace(ns,"all",pat,ignore_case=True, |
|
97 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=True, | |
|
98 | show_all=False).keys() | |||
81 | a.sort() |
|
99 | a.sort() | |
82 | self.assertEqual(a,res) |
|
100 | self.assertEqual(a,res) | |
83 |
|
101 | |||
@@ -85,16 +103,15 b' class Tests (unittest.TestCase):' | |||||
85 | ns=root.__dict__ |
|
103 | ns=root.__dict__ | |
86 | tests=[ |
|
104 | tests=[ | |
87 | ("a*", ["abbot","abel","ABEL","active","arna",]), |
|
105 | ("a*", ["abbot","abel","ABEL","active","arna",]), | |
88 |
("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop", |
|
106 | ("?b*.?o*",["abbot.koppel","abbot.loop","abel.koppel","abel.loop", | |
|
107 | "ABEL.koppel","ABEL.loop",]), | |||
89 | ("_a*", ["_apan","_APAN"]), |
|
108 | ("_a*", ["_apan","_APAN"]), | |
90 | ("_*anka", ["__anka","__ANKA",]), |
|
109 | ("_*anka", ["__anka","__ANKA",]), | |
91 | ("_*a*", ["__anka","__ANKA","_apan","_APAN"]), |
|
110 | ("_*a*", ["__anka","__ANKA","_apan","_APAN"]), | |
92 | ] |
|
111 | ] | |
93 | for pat,res in tests: |
|
112 | for pat,res in tests: | |
94 | res.sort() |
|
113 | res.sort() | |
95 |
a=wildcard.list_namespace(ns,"all",pat,ignore_case=True, |
|
114 | a=wildcard.list_namespace(ns,"all",pat,ignore_case=True, | |
|
115 | show_all=True).keys() | |||
96 | a.sort() |
|
116 | a.sort() | |
97 | self.assertEqual(a,res) |
|
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 | add_package(packages, 'deathrow', tests=True) |
|
108 | add_package(packages, 'deathrow', tests=True) | |
109 | add_package(packages, 'extensions') |
|
109 | add_package(packages, 'extensions') | |
110 | add_package(packages, 'external') |
|
110 | add_package(packages, 'external') | |
111 |
add_package(packages, 'frontend' |
|
111 | add_package(packages, 'frontend') | |
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') |
|
|||
119 | add_package(packages, 'frontend.qt') |
|
112 | add_package(packages, 'frontend.qt') | |
120 | add_package(packages, 'frontend.qt.console') |
|
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 | add_package(packages, 'kernel', config=False, tests=True, scripts=True) |
|
114 | add_package(packages, 'kernel', config=False, tests=True, scripts=True) | |
125 | add_package(packages, 'kernel.core', config=False, tests=True) |
|
115 | add_package(packages, 'kernel.core', config=False, tests=True) | |
126 | add_package(packages, 'lib', tests=True) |
|
116 | add_package(packages, 'lib', tests=True) |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now