Show More
@@ -0,0 +1,31 b'' | |||
|
1 | """ Run ipython unit tests | |
|
2 | ||
|
3 | This should be launched from inside ipython by "%run runtests.py" | |
|
4 | or through ipython command line "ipython runtests.py". | |
|
5 | ||
|
6 | """ | |
|
7 | ||
|
8 | from path import path | |
|
9 | import pprint,os | |
|
10 | import IPython.ipapi | |
|
11 | ip = IPython.ipapi.get() | |
|
12 | ||
|
13 | def main(): | |
|
14 | all = path('.').files('test_*py') | |
|
15 | results = {} | |
|
16 | res_exc = [None] | |
|
17 | def exchook(self,*e): | |
|
18 | res_exc[0] = [e] | |
|
19 | ip.IP.set_custom_exc((Exception,), exchook) | |
|
20 | startdir = os.getcwd() | |
|
21 | for test in all: | |
|
22 | print test | |
|
23 | res_exc[0] = 'ok' | |
|
24 | os.chdir(startdir) | |
|
25 | ip.runlines(test.text()) | |
|
26 | results[str(test)] = res_exc[0] | |
|
27 | ||
|
28 | os.chdir(startdir) | |
|
29 | pprint.pprint(results) | |
|
30 | ||
|
31 | main() No newline at end of file |
@@ -0,0 +1,6 b'' | |||
|
1 | import os | |
|
2 | cd / | |
|
3 | assert os.getcwd() == '/' | |
|
4 | %cd /tmp | |
|
5 | ||
|
6 | assert os.getcwd() == '/tmp' |
@@ -0,0 +1,3 b'' | |||
|
1 | # this will fail w/ assertionerror | |
|
2 | cd / | |
|
3 | assert os.getcwd() == '/does/not/exist' |
@@ -102,6 +102,8 b' class IPApi:' | |||
|
102 | 102 | |
|
103 | 103 | self.set_hook = ip.set_hook |
|
104 | 104 | |
|
105 | self.set_custom_exc = ip.set_custom_exc | |
|
106 | ||
|
105 | 107 | self.IP = ip |
|
106 | 108 | global _recent |
|
107 | 109 | _recent = self |
@@ -155,6 +157,17 b' class IPApi:' | |||
|
155 | 157 | Return a PickleShareDB object. |
|
156 | 158 | """ |
|
157 | 159 | return self.IP.db |
|
160 | def runlines(self,lines): | |
|
161 | """ Run the specified lines in interpreter, honoring ipython directives. | |
|
162 | ||
|
163 | This allows %magic and !shell escape notations. | |
|
164 | ||
|
165 | Takes either all lines in one string or list of lines. | |
|
166 | """ | |
|
167 | if isinstance(lines,basestring): | |
|
168 | self.IP.runlines(lines) | |
|
169 | else: | |
|
170 | self.IP.runlines('\n'.join(lines)) | |
|
158 | 171 | |
|
159 | 172 | |
|
160 | 173 | def launch_new_instance(user_ns = None): |
@@ -1,3 +1,10 b'' | |||
|
1 | 2006-02-09 Ville Vainio <vivainio@gmail.com> | |
|
2 | ||
|
3 | * test/*: Added a unit testing framework (finally). | |
|
4 | '%run runtests.py' to run test_*. | |
|
5 | ||
|
6 | * ipapi.py: Exposed runlines and set_custom_exc | |
|
7 | ||
|
1 | 8 | 2006-02-07 Ville Vainio <vivainio@gmail.com> |
|
2 | 9 | |
|
3 | 10 | * iplib.py: don't split "f 1 2" to "f(1,2)" in autocall, |
General Comments 0
You need to be logged in to leave comments.
Login now