Show More
@@ -80,18 +80,6 b' class IPDoctestOutputChecker(doctest.OutputChecker):' | |||||
80 | class IPExample(doctest.Example): pass |
|
80 | class IPExample(doctest.Example): pass | |
81 |
|
81 | |||
82 |
|
82 | |||
83 | class IPExternalExample(doctest.Example): |
|
|||
84 | """Doctest examples to be run in an external process.""" |
|
|||
85 |
|
||||
86 | def __init__(self, source, want, exc_msg=None, lineno=0, indent=0, |
|
|||
87 | options=None): |
|
|||
88 | # Parent constructor |
|
|||
89 | doctest.Example.__init__(self,source,want,exc_msg,lineno,indent,options) |
|
|||
90 |
|
||||
91 | # An EXTRA newline is needed to prevent pexpect hangs |
|
|||
92 | self.source += '\n' |
|
|||
93 |
|
||||
94 |
|
||||
95 | class IPDocTestParser(doctest.DocTestParser): |
|
83 | class IPDocTestParser(doctest.DocTestParser): | |
96 | """ |
|
84 | """ | |
97 | A class used to parse strings containing doctest examples. |
|
85 | A class used to parse strings containing doctest examples. | |
@@ -137,9 +125,6 b' class IPDocTestParser(doctest.DocTestParser):' | |||||
137 | # we don't need to modify any other code. |
|
125 | # we don't need to modify any other code. | |
138 | _RANDOM_TEST = re.compile(r'#\s*all-random\s+') |
|
126 | _RANDOM_TEST = re.compile(r'#\s*all-random\s+') | |
139 |
|
127 | |||
140 | # Mark tests to be executed in an external process - currently unsupported. |
|
|||
141 | _EXTERNAL_IP = re.compile(r'#\s*ipdoctest:\s*EXTERNAL') |
|
|||
142 |
|
||||
143 | def ip2py(self,source): |
|
128 | def ip2py(self,source): | |
144 | """Convert input IPython source into valid Python.""" |
|
129 | """Convert input IPython source into valid Python.""" | |
145 | block = _ip.input_transformer_manager.transform_cell(source) |
|
130 | block = _ip.input_transformer_manager.transform_cell(source) | |
@@ -182,27 +167,12 b' class IPDocTestParser(doctest.DocTestParser):' | |||||
182 | terms = list(self._EXAMPLE_RE_PY.finditer(string)) |
|
167 | terms = list(self._EXAMPLE_RE_PY.finditer(string)) | |
183 | if terms: |
|
168 | if terms: | |
184 | # Normal Python example |
|
169 | # Normal Python example | |
185 | #print '-'*70 # dbg |
|
|||
186 | #print 'PyExample, Source:\n',string # dbg |
|
|||
187 | #print '-'*70 # dbg |
|
|||
188 | Example = doctest.Example |
|
170 | Example = doctest.Example | |
189 | else: |
|
171 | else: | |
190 |
# It's an ipython example. |
|
172 | # It's an ipython example. | |
191 | # in-process, so their syntax must be turned into valid python. |
|
|||
192 | # IPExternalExamples are run out-of-process (via pexpect) so they |
|
|||
193 | # don't need any filtering (a real ipython will be executing them). |
|
|||
194 | terms = list(self._EXAMPLE_RE_IP.finditer(string)) |
|
173 | terms = list(self._EXAMPLE_RE_IP.finditer(string)) | |
195 | if self._EXTERNAL_IP.search(string): |
|
174 | Example = IPExample | |
196 | #print '-'*70 # dbg |
|
175 | ip2py = True | |
197 | #print 'IPExternalExample, Source:\n',string # dbg |
|
|||
198 | #print '-'*70 # dbg |
|
|||
199 | Example = IPExternalExample |
|
|||
200 | else: |
|
|||
201 | #print '-'*70 # dbg |
|
|||
202 | #print 'IPExample, Source:\n',string # dbg |
|
|||
203 | #print '-'*70 # dbg |
|
|||
204 | Example = IPExample |
|
|||
205 | ip2py = True |
|
|||
206 |
|
176 | |||
207 | for m in terms: |
|
177 | for m in terms: | |
208 | # Add the pre-example text to `output`. |
|
178 | # Add the pre-example text to `output`. | |
@@ -217,10 +187,6 b' class IPDocTestParser(doctest.DocTestParser):' | |||||
217 | # cases, it's only non-empty for 'all-random' tests): |
|
187 | # cases, it's only non-empty for 'all-random' tests): | |
218 | want += random_marker |
|
188 | want += random_marker | |
219 |
|
189 | |||
220 | if Example is IPExternalExample: |
|
|||
221 | options[doctest.NORMALIZE_WHITESPACE] = True |
|
|||
222 | want += '\n' |
|
|||
223 |
|
||||
224 | # Create an Example, and add it to the list. |
|
190 | # Create an Example, and add it to the list. | |
225 | if not self._IS_BLANK_OR_COMMENT(source): |
|
191 | if not self._IS_BLANK_OR_COMMENT(source): | |
226 | output.append(Example(source, want, exc_msg, |
|
192 | output.append(Example(source, want, exc_msg, |
General Comments 0
You need to be logged in to leave comments.
Login now