Skip to content

Commit a5fe9cf

Browse files
WillAydgfyoung
authored andcommitted
TST: Add capture_stderr decorator to test_validate_docstrings (pandas-dev#22543)
1 parent 3285bdc commit a5fe9cf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pandas/util/testing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ def capture_stderr(f):
673673
AssertionError: assert 'foo\n' == 'bar\n'
674674
"""
675675

676-
@wraps(f)
676+
@compat.wraps(f)
677677
def wrapper(*args, **kwargs):
678678
try:
679679
sys.stderr = StringIO()

scripts/tests/test_validate_docstrings.py

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import validate_docstrings
77
validate_one = validate_docstrings.validate_one
88

9+
from pandas.util.testing import capture_stderr
10+
911

1012
class GoodDocStrings(object):
1113
"""
@@ -518,21 +520,25 @@ def _import_path(self, klass=None, func=None):
518520

519521
return base_path
520522

523+
@capture_stderr
521524
def test_good_class(self):
522525
assert validate_one(self._import_path(
523526
klass='GoodDocStrings')) == 0
524527

528+
@capture_stderr
525529
@pytest.mark.parametrize("func", [
526530
'plot', 'sample', 'random_letters', 'sample_values', 'head', 'head1',
527531
'contains', 'mode'])
528532
def test_good_functions(self, func):
529533
assert validate_one(self._import_path(
530534
klass='GoodDocStrings', func=func)) == 0
531535

536+
@capture_stderr
532537
def test_bad_class(self):
533538
assert validate_one(self._import_path(
534539
klass='BadGenericDocStrings')) > 0
535540

541+
@capture_stderr
536542
@pytest.mark.parametrize("func", [
537543
'func', 'astype', 'astype1', 'astype2', 'astype3', 'plot', 'method'])
538544
def test_bad_generic_functions(self, func):

0 commit comments

Comments
 (0)