Check output, accepting special markers embedded in the output. If the output didn't pass the default validation but the special string '#random' is included, we accept it.
(self, want, got, optionflags)
| 58 | random_re = re.compile(r'#\s*random\s+') |
| 59 | |
| 60 | def check_output(self, want, got, optionflags): |
| 61 | """Check output, accepting special markers embedded in the output. |
| 62 | |
| 63 | If the output didn't pass the default validation but the special string |
| 64 | '#random' is included, we accept it.""" |
| 65 | |
| 66 | # Let the original tester verify first, in case people have valid tests |
| 67 | # that happen to have a comment saying '#random' embedded in. |
| 68 | ret = doctest.OutputChecker.check_output(self, want, got, |
| 69 | optionflags) |
| 70 | if not ret and self.random_re.search(want): |
| 71 | # print('RANDOM OK:',want, file=sys.stderr) # dbg |
| 72 | return True |
| 73 | |
| 74 | return ret |
| 75 | |
| 76 | |
| 77 | # A simple subclassing of the original with a different class name, so we can |