From 43f7f7cc6bc7d3f1ac2a3bb428129f604b1eba82 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 30 Aug 2018 08:09:05 -0700 Subject: [PATCH 1/2] Added capture_stderr decorator --- pandas/tests/scripts/test_validate_docstrings.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pandas/tests/scripts/test_validate_docstrings.py b/pandas/tests/scripts/test_validate_docstrings.py index 25cb1d7aff649..0ba1209d7c7a7 100644 --- a/pandas/tests/scripts/test_validate_docstrings.py +++ b/pandas/tests/scripts/test_validate_docstrings.py @@ -4,6 +4,8 @@ import numpy as np import pytest +from pandas.util.testing import capture_stderr + class GoodDocStrings(object): """ @@ -553,10 +555,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( # noqa: F821 klass='GoodDocStrings')) == 0 + @capture_stderr @pytest.mark.parametrize("func", [ 'plot', 'sample', 'random_letters', 'sample_values', 'head', 'head1', 'contains', 'mode']) @@ -564,10 +568,12 @@ def test_good_functions(self, func): assert validate_one(self._import_path( # noqa: F821 klass='GoodDocStrings', func=func)) == 0 + @capture_stderr def test_bad_class(self): assert validate_one(self._import_path( # noqa: F821 klass='BadGenericDocStrings')) > 0 + @capture_stderr @pytest.mark.parametrize("func", [ 'func', 'astype', 'astype1', 'astype2', 'astype3', 'plot', 'method']) def test_bad_generic_functions(self, func): From 49ea82d0895b749abc046d2f6915e089bc46f2f3 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 30 Aug 2018 10:09:12 -0700 Subject: [PATCH 2/2] Py27 compat --- pandas/util/testing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()