diff --git a/pandas/tests/indexes/datetimes/test_datetime.py b/pandas/tests/indexes/datetimes/test_datetime.py index c338026025767..e76de2ebedf67 100644 --- a/pandas/tests/indexes/datetimes/test_datetime.py +++ b/pandas/tests/indexes/datetimes/test_datetime.py @@ -1,5 +1,4 @@ from datetime import date -import sys import dateutil import numpy as np @@ -125,15 +124,14 @@ def test_map(self): exp = Index([f(x) for x in rng], dtype='>> from pandas.util.testing import capture_stderr - >>> import sys - >>> - >>> @capture_stderr - ... def test_stderr_pass(): - ... sys.stderr.write("foo") - ... out = sys.stderr.getvalue() - ... assert out == "foo\n" - >>> - >>> @capture_stderr - ... def test_stderr_fail(): - ... sys.stderr.write("foo") - ... out = sys.stderr.getvalue() - ... assert out == "bar\n" - ... - AssertionError: assert 'foo\n' == 'bar\n' - """ - - @compat.wraps(f) - def wrapper(*args, **kwargs): - try: - sys.stderr = StringIO() - f(*args, **kwargs) - finally: - sys.stderr = sys.__stderr__ - - return wrapper - # ----------------------------------------------------------------------------- # Console debugging tools diff --git a/scripts/tests/test_validate_docstrings.py b/scripts/tests/test_validate_docstrings.py index ca09cbb23d145..3d16fecb4ec3c 100644 --- a/scripts/tests/test_validate_docstrings.py +++ b/scripts/tests/test_validate_docstrings.py @@ -4,7 +4,6 @@ import textwrap import pytest import numpy as np -from pandas.util.testing import capture_stderr import validate_docstrings validate_one = validate_docstrings.validate_one @@ -739,36 +738,32 @@ def _import_path(self, klass=None, func=None): return base_path - @capture_stderr - def test_good_class(self): + def test_good_class(self, capsys): errors = validate_one(self._import_path( klass='GoodDocStrings'))['errors'] assert isinstance(errors, list) assert not errors - @capture_stderr @pytest.mark.parametrize("func", [ 'plot', 'sample', 'random_letters', 'sample_values', 'head', 'head1', 'contains', 'mode', 'good_imports']) - def test_good_functions(self, func): + def test_good_functions(self, capsys, func): errors = validate_one(self._import_path( klass='GoodDocStrings', func=func))['errors'] assert isinstance(errors, list) assert not errors - @capture_stderr - def test_bad_class(self): + def test_bad_class(self, capsys): errors = validate_one(self._import_path( klass='BadGenericDocStrings'))['errors'] assert isinstance(errors, list) assert errors - @capture_stderr @pytest.mark.parametrize("func", [ 'func', 'astype', 'astype1', 'astype2', 'astype3', 'plot', 'method', 'private_classes', ]) - def test_bad_generic_functions(self, func): + def test_bad_generic_functions(self, capsys, func): errors = validate_one(self._import_path( # noqa:F821 klass='BadGenericDocStrings', func=func))['errors'] assert isinstance(errors, list)