Show More
@@ -87,7 +87,7 b' def parse_test_output(txt):' | |||||
87 | txt : str |
|
87 | txt : str | |
88 | Text output of a test run, assumed to contain a line of one of the |
|
88 | Text output of a test run, assumed to contain a line of one of the | |
89 | following forms:: |
|
89 | following forms:: | |
90 |
|
90 | |||
91 | 'FAILED (errors=1)' |
|
91 | 'FAILED (errors=1)' | |
92 | 'FAILED (failures=1)' |
|
92 | 'FAILED (failures=1)' | |
93 | 'FAILED (errors=1, failures=1)' |
|
93 | 'FAILED (errors=1, failures=1)' | |
@@ -186,7 +186,7 b' def ipexec(fname, options=None, commands=()):' | |||||
186 |
|
186 | |||
187 | Returns |
|
187 | Returns | |
188 | ------- |
|
188 | ------- | |
189 | (stdout, stderr) of ipython subprocess. |
|
189 | ``(stdout, stderr)`` of ipython subprocess. | |
190 | """ |
|
190 | """ | |
191 | if options is None: options = [] |
|
191 | if options is None: options = [] | |
192 |
|
192 | |||
@@ -333,13 +333,13 b' notprinted_msg = """Did not find {0!r} in printed output (on {1}):' | |||||
333 |
|
333 | |||
334 | class AssertPrints(object): |
|
334 | class AssertPrints(object): | |
335 | """Context manager for testing that code prints certain text. |
|
335 | """Context manager for testing that code prints certain text. | |
336 |
|
336 | |||
337 | Examples |
|
337 | Examples | |
338 | -------- |
|
338 | -------- | |
339 | >>> with AssertPrints("abc", suppress=False): |
|
339 | >>> with AssertPrints("abc", suppress=False): | |
340 | ... print("abcd") |
|
340 | ... print("abcd") | |
341 | ... print("def") |
|
341 | ... print("def") | |
342 |
... |
|
342 | ... | |
343 | abcd |
|
343 | abcd | |
344 | def |
|
344 | def | |
345 | """ |
|
345 | """ | |
@@ -349,13 +349,13 b' class AssertPrints(object):' | |||||
349 | self.s = [self.s] |
|
349 | self.s = [self.s] | |
350 | self.channel = channel |
|
350 | self.channel = channel | |
351 | self.suppress = suppress |
|
351 | self.suppress = suppress | |
352 |
|
352 | |||
353 | def __enter__(self): |
|
353 | def __enter__(self): | |
354 | self.orig_stream = getattr(sys, self.channel) |
|
354 | self.orig_stream = getattr(sys, self.channel) | |
355 | self.buffer = MyStringIO() |
|
355 | self.buffer = MyStringIO() | |
356 | self.tee = Tee(self.buffer, channel=self.channel) |
|
356 | self.tee = Tee(self.buffer, channel=self.channel) | |
357 | setattr(sys, self.channel, self.buffer if self.suppress else self.tee) |
|
357 | setattr(sys, self.channel, self.buffer if self.suppress else self.tee) | |
358 |
|
358 | |||
359 | def __exit__(self, etype, value, traceback): |
|
359 | def __exit__(self, etype, value, traceback): | |
360 | try: |
|
360 | try: | |
361 | if value is not None: |
|
361 | if value is not None: | |
@@ -381,7 +381,7 b' printed_msg = """Found {0!r} in printed output (on {1}):' | |||||
381 |
|
381 | |||
382 | class AssertNotPrints(AssertPrints): |
|
382 | class AssertNotPrints(AssertPrints): | |
383 | """Context manager for checking that certain output *isn't* produced. |
|
383 | """Context manager for checking that certain output *isn't* produced. | |
384 |
|
384 | |||
385 | Counterpart of AssertPrints""" |
|
385 | Counterpart of AssertPrints""" | |
386 | def __exit__(self, etype, value, traceback): |
|
386 | def __exit__(self, etype, value, traceback): | |
387 | try: |
|
387 | try: |
General Comments 0
You need to be logged in to leave comments.
Login now