GeezerVison is showing github.com — Test all the doc snippets · Issue #2535 · googleapis/google-cloud-python
Test all the doc snippets #2535Activitydhermes commented on Oct 12, 2016 We may want a script which explicitly checks and (complains about / errors in the presence of) snippets in RST files or docstrings? daspecster commented on Oct 12, 2016 ContributorAuthor More actions @dhermes you mean check for unmarked snippets/code blocks? Can you clarify that?
Use system test environment?
I think @tseaver mentioned something about not wanting to write a lot of mocks for snippets?
With that in mind, couldn't we just test the snippets through the system tests? That seems like the most direct testing strategy. dhermes commented on Oct 12, 2016 @daspecster Not sure what you mean by unmarked. I simply mean a script which makes sure all of our snippets must be valid and test-able. So if there is just some code-block somewhere without doctest, then we flag it as untested. daspecster commented on Oct 12, 2016 ContributorAuthor More actions @dhermes gotcha.
Snippets are referenced via...
.. literalinclude:: bigquery_snippets.py
:start-after: [START client_list_datasets]
:end-before: [END client_list_datasets]
So you could just check for .. code-block::'s or ::'s.
However I don't know if we would want to test things like...
.. code-block:: console
$ pip install google-cloud
Could just look for .. code-block:: python I suppose. dhermes commented on Oct 12, 2016 @daspecster Yeah I wasn't trying to spec out how the script would work, just trying to say we should have a check. Otherwise snippets may leak in. There might be a Sphinx extension to check for it already? daspecster commented on Oct 12, 2016 ContributorAuthor More actions Yeah sorry, probably the wrong place to spec it out. I added a checkbox for a validation script. dhermes commented on Oct 13, 2016 Reacted by Thomas Schultz tseaver commented on Oct 14, 2016 @dhermes Our goals for testing snippets inline:
- Snippets have no syntax errors. We could mock everything to satisfy this case.
- Snippets calls to each API match their signatures. Here, we would have to mock things at the connection / stub / helper level. We would still not catch stuff where the values passed in matched the names of expected arguments, but failed to marshal properly, or match what the back-end mandates in some other way.
- Snippets show actually correct processing of results as they would be returned by the API. Here we would be required to mock everything about the back-end for each API.
I don't believe we can reasonably expect to do the second or third options inside the test setup / teardown facilities provided by Sphinx. Exercising the snippets in a system-test-like environment, against the real APIs, seems like the only viable choice. Reacted by Thomas Schultz dhermes commented on Oct 14, 2016 @tseaver That's fine with me. (The thing I spec-ed out was really just to show how we could make sure the literal blocks adhere to whatever standards we desire. So if we wanted them all to be literalinclude we could check for that.) lukesneeringer commented on Aug 11, 2017 Hello,
One of the challenges of maintaining a large open source project is that sometimes, you can bite off more than you can chew. As the lead maintainer of google-cloud-python, I can definitely say that I have let the issues here pile up.
As part of trying to get things under control (as well as to empower us to provide better customer service in the future), I am declaring a "bankruptcy" of sorts on many of the old issues, especially those likely to have been addressed or made obsolete by more recent updates.
My goal is to close stale issues whose relevance or solution is no longer immediately evident, and which appear to be of lower importance. I believe in good faith that this is one of those issues, but I am scanning quickly and may occasionally be wrong. If this is an issue of high importance, please comment here and we will reconsider. If this is an issue whose solution is trivial, please consider providing a pull request.
Thank you! dhermes commented on Aug 11, 2017 @lukesneeringer This should definitely be done. I actually have a simple Sphinx extension which requires that all code blocks are either doctests or not Python. We could easily enforce a "no snippets that aren't doctested" policy using that.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|