-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Changes from 3 commits
b31fc10
5d2815f
5bb7b9b
86327d4
188f4a3
0d25298
577308e
156b997
3a5e7fd
1a8aee9
aa4807a
1d2c5c0
db782fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,25 +490,25 @@ 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 | ||
assert len(validate_one(self._import_path( # noqa: F821 | ||
klass='GoodDocStrings'))['errors']) == 0 | ||
|
||
@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 | ||
assert len(validate_one(self._import_path( # noqa: F821 | ||
klass='GoodDocStrings', func=func))['errors']) == 0 | ||
|
||
def test_bad_class(self): | ||
assert validate_one(self._import_path( # noqa: F821 | ||
klass='BadGenericDocStrings')) > 0 | ||
assert len(validate_one(self._import_path( # noqa: F821 | ||
klass='BadGenericDocStrings'))['errors']) > 0 | ||
|
||
@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 | ||
assert len(validate_one(self._import_path( # noqa:F821 | ||
klass='BadGenericDocStrings', func=func))['errors']) > 0 | ||
|
||
@pytest.mark.parametrize("klass,func,msgs", [ | ||
# Summary tests | ||
|
@@ -546,7 +546,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 | ||
res = validate_one(self._import_path(klass=klass, func=func)) # noqa:F821 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency let's use |
||
for msg in msgs: | ||
assert msg in err | ||
assert msg in ''.join(res['errors']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to join as a string here or can we just check for inclusion in the list? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm not wrong, the messages we're checking are no the whole error message, but part of it. So, this is equivalent to something like:
I think it makes more sense to use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For PEP8 can just use implicit truthiness of empty list, so just
not ...['errors']
instead oflen(...['errors']) == 0
. Applicable to other tests belowThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general that is true, however in this case I think it is good to test it is actually a zero-length list and not something else Falsey?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on both comments, I'll change as @WillAyd suggests, and will also assert that the result is a list.