|
20 | 20 | from pandas._libs import testing as _testing
|
21 | 21 | import pandas.compat as compat
|
22 | 22 | from pandas.compat import (
|
23 |
| - PY2, PY3, Counter, StringIO, callable, filter, httplib, lmap, lrange, lzip, |
24 |
| - map, raise_with_traceback, range, string_types, u, unichr, zip) |
| 23 | + PY2, PY3, Counter, callable, filter, httplib, lmap, lrange, lzip, map, |
| 24 | + raise_with_traceback, range, string_types, u, unichr, zip) |
25 | 25 |
|
26 | 26 | from pandas.core.dtypes.common import (
|
27 | 27 | is_bool, is_categorical_dtype, is_datetime64_dtype, is_datetime64tz_dtype,
|
@@ -637,53 +637,6 @@ def set_defaultencoding(encoding):
|
637 | 637 | sys.setdefaultencoding(orig)
|
638 | 638 |
|
639 | 639 |
|
640 |
| -def capture_stdout(f): |
641 |
| - r""" |
642 |
| - Decorator to capture stdout in a buffer so that it can be checked |
643 |
| - (or suppressed) during testing. |
644 |
| -
|
645 |
| - Parameters |
646 |
| - ---------- |
647 |
| - f : callable |
648 |
| - The test that is capturing stdout. |
649 |
| -
|
650 |
| - Returns |
651 |
| - ------- |
652 |
| - f : callable |
653 |
| - The decorated test ``f``, which captures stdout. |
654 |
| -
|
655 |
| - Examples |
656 |
| - -------- |
657 |
| -
|
658 |
| - >>> from pandas.util.testing import capture_stdout |
659 |
| - >>> import sys |
660 |
| - >>> |
661 |
| - >>> @capture_stdout |
662 |
| - ... def test_print_pass(): |
663 |
| - ... print("foo") |
664 |
| - ... out = sys.stdout.getvalue() |
665 |
| - ... assert out == "foo\n" |
666 |
| - >>> |
667 |
| - >>> @capture_stdout |
668 |
| - ... def test_print_fail(): |
669 |
| - ... print("foo") |
670 |
| - ... out = sys.stdout.getvalue() |
671 |
| - ... assert out == "bar\n" |
672 |
| - ... |
673 |
| - AssertionError: assert 'foo\n' == 'bar\n' |
674 |
| - """ |
675 |
| - |
676 |
| - @compat.wraps(f) |
677 |
| - def wrapper(*args, **kwargs): |
678 |
| - try: |
679 |
| - sys.stdout = StringIO() |
680 |
| - f(*args, **kwargs) |
681 |
| - finally: |
682 |
| - sys.stdout = sys.__stdout__ |
683 |
| - |
684 |
| - return wrapper |
685 |
| - |
686 |
| - |
687 | 640 | # -----------------------------------------------------------------------------
|
688 | 641 | # Console debugging tools
|
689 | 642 |
|
|
0 commit comments