diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 1eedb9e2a8274..1f6214e64f9c2 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -673,7 +673,7 @@ def capture_stderr(f): AssertionError: assert 'foo\n' == 'bar\n' """ - @wraps(f) + @compat.wraps(f) def wrapper(*args, **kwargs): try: sys.stderr = StringIO() diff --git a/scripts/tests/test_validate_docstrings.py b/scripts/tests/test_validate_docstrings.py index 933d02cc8c627..0c0757c6963d7 100644 --- a/scripts/tests/test_validate_docstrings.py +++ b/scripts/tests/test_validate_docstrings.py @@ -6,6 +6,8 @@ import validate_docstrings validate_one = validate_docstrings.validate_one +from pandas.util.testing import capture_stderr + class GoodDocStrings(object): """ @@ -518,10 +520,12 @@ def _import_path(self, klass=None, func=None): return base_path + @capture_stderr def test_good_class(self): assert validate_one(self._import_path( klass='GoodDocStrings')) == 0 + @capture_stderr @pytest.mark.parametrize("func", [ 'plot', 'sample', 'random_letters', 'sample_values', 'head', 'head1', 'contains', 'mode']) @@ -529,10 +533,12 @@ def test_good_functions(self, func): assert validate_one(self._import_path( klass='GoodDocStrings', func=func)) == 0 + @capture_stderr def test_bad_class(self): assert validate_one(self._import_path( klass='BadGenericDocStrings')) > 0 + @capture_stderr @pytest.mark.parametrize("func", [ 'func', 'astype', 'astype1', 'astype2', 'astype3', 'plot', 'method']) def test_bad_generic_functions(self, func):