Skip to content

Conversation

@dhermes
Copy link
Contributor

@dhermes dhermes commented Dec 7, 2016

It's worth noting that I delegated clean-up to system_tests/datastore.py::tearDownModule. This is because (in my experimenting) I discovered that the sphinx.ext.doctest directive testcleanup doesn't run when the thing being tested fails. (FWIW, I think it'd be fairly easy for one of us to send a PR to the Sphinx project and fix that behavior, but that was outside the scope of this PR.)


To make dev a little faster I did the following:

$ tox -e system-tests --recreate --notest
$ source .tox/system-tests/bin/activate
$ GOOGLE_CLOUD_DISABLE_GRPC=true \
> .tox/system-tests/bin/py.test system_tests/datastore.py \
> -k TestDoctest -s -vv

and every time I made a change I just re-installed into the env

$ .tox/system-tests/bin/pip install --upgrade datastore/

Might be worth turning this into a script someday? But I don't want to design it before we know how we'll use it. Just putting it here for posterity.


There is a code-block snippet in datastore._http but that module is non-public so I left it alone.


This package could use some more snippets, but for now at least they are all covered.

@dhermes dhermes added api: datastore Issues related to the Datastore API. docs labels Dec 7, 2016
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 7, 2016
@daspecster
Copy link
Contributor

I like it!

@dhermes dhermes merged commit 6b93d40 into googleapis:master Dec 8, 2016
@dhermes dhermes deleted the moar-datastore-doctests branch December 8, 2016 21:50
@dhermes
Copy link
Contributor Author

dhermes commented Dec 8, 2016

Blerg! Python 2 and 3 strike again:
https://travis-ci.org/GoogleCloudPlatform/google-cloud-python/builds/182425545#L2280

Failed example:
    client.get(key)
Expected:
    <Entity(u'EntityKind', 1234L) {u'property': 'value'}>
Got:
    <Entity('EntityKind', 1234) {'property': 'value'}>

Proposed short-term "fix": Only run snippet tests in Python 2? @jonparrott and @tseaver any better ideas?

@tseaver
Copy link
Contributor

tseaver commented Dec 9, 2016

@dhermes I hate any testing dependency on repr, period (and tracebacks even worse).

@dhermes
Copy link
Contributor Author

dhermes commented Dec 9, 2016

@tseaver Yes I'm aware of your strong opinion. Any construction constructive suggestion?

@tseaver
Copy link
Contributor

tseaver commented Dec 9, 2016

@dhermes Either change the example not to use the repr, or change the repr not to use the "dict literal" repr of the keys / values.

richkadel pushed a commit to richkadel/google-cloud-python that referenced this pull request May 6, 2017
Converting remaining datastore snippets to doctests
parthea pushed a commit that referenced this pull request Nov 24, 2025
Converting remaining datastore snippets to doctests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: datastore Issues related to the Datastore API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants