MCPcopy Create free account
hub / github.com/ipython/ipython / IPDoctestOutputChecker

Class IPDoctestOutputChecker

IPython/testing/plugin/ipdoctest.py:170–193  ·  view source on GitHub ↗

Second-chance checker with support for random tests. If the default comparison doesn't pass, this checker looks in the expected output string for flags that tell us to ignore the output.

Source from the content-addressed store, hash-verified

168
169
170class IPDoctestOutputChecker(doctest.OutputChecker):
171 """Second-chance checker with support for random tests.
172
173 If the default comparison doesn't pass, this checker looks in the expected
174 output string for flags that tell us to ignore the output.
175 """
176
177 random_re = re.compile(r'#\s*random\s+')
178
179 def check_output(self, want, got, optionflags):
180 """Check output, accepting special markers embedded in the output.
181
182 If the output didn't pass the default validation but the special string
183 '#random' is included, we accept it."""
184
185 # Let the original tester verify first, in case people have valid tests
186 # that happen to have a comment saying '#random' embedded in.
187 ret = doctest.OutputChecker.check_output(self, want, got,
188 optionflags)
189 if not ret and self.random_re.search(want):
190 #print >> sys.stderr, 'RANDOM OK:',want # dbg
191 return True
192
193 return ret
194
195
196class DocTestCase(doctests.DocTestCase):

Callers 2

configureMethod · 0.85
configureMethod · 0.85

Calls

no outgoing calls

Tested by 2

configureMethod · 0.68
configureMethod · 0.68