Skip to content

Changes to validate_docstring script to be able to check all docstrings at once #22408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 13, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions pandas/tests/scripts/test_validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,25 +490,33 @@ def _import_path(self, klass=None, func=None):
return base_path

def test_good_class(self):
assert validate_one(self._import_path( # noqa: F821
klass='GoodDocStrings')) == 0
errors = validate_one(self._import_path( # noqa: F821
klass='GoodDocStrings'))['errors']
assert isinstance(errors, list)
assert not errors

@pytest.mark.parametrize("func", [
'plot', 'sample', 'random_letters', 'sample_values', 'head', 'head1',
'contains'])
def test_good_functions(self, func):
assert validate_one(self._import_path( # noqa: F821
klass='GoodDocStrings', func=func)) == 0
errors = validate_one(self._import_path( # noqa: F821
klass='GoodDocStrings', func=func))['errors']
assert isinstance(errors, list)
assert not errors

def test_bad_class(self):
assert validate_one(self._import_path( # noqa: F821
klass='BadGenericDocStrings')) > 0
errors = validate_one(self._import_path( # noqa: F821
klass='BadGenericDocStrings'))['errors']
assert isinstance(errors, list)
assert errors

@pytest.mark.parametrize("func", [
'func', 'astype', 'astype1', 'astype2', 'astype3', 'plot', 'method'])
def test_bad_generic_functions(self, func):
assert validate_one(self._import_path( # noqa:F821
klass='BadGenericDocStrings', func=func)) > 0
errors = validate_one(self._import_path( # noqa:F821
klass='BadGenericDocStrings', func=func))['errors']
assert isinstance(errors, list)
assert errors

@pytest.mark.parametrize("klass,func,msgs", [
# Summary tests
Expand Down Expand Up @@ -546,7 +554,6 @@ def test_bad_generic_functions(self, func):
marks=pytest.mark.xfail)
])
def test_bad_examples(self, capsys, klass, func, msgs):
validate_one(self._import_path(klass=klass, func=func)) # noqa:F821
err = capsys.readouterr().err
result = validate_one(self._import_path(klass=klass, func=func)) # noqa:F821
for msg in msgs:
assert msg in err
assert msg in ' '.join(result['errors'])
Loading