question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get doctests in shape to be tested by tox

See original GitHub issue

Make tox test all the doctests in the Sphinx docs.

Ours aren’t in shape to do that (yet, might be hard to get there).

See comment by @tseaver for more context

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:33 (33 by maintainers)

github_iconTop GitHub Comments

1reaction
dhermescommented, Oct 25, 2016

@daspecster As seen above (I edited after original posting), doctest.run_docstring_examples doesn’t actually fail in the case of an error, so using the unit test runner allows us to see failures as exceptions / nonzero exit codes.

1reaction
dhermescommented, Oct 25, 2016

Please file an issue saying “I’m working on storage snippets”.


In storage_snippets.py you would do the following:

SNIPPET_GET_BLOB = """\
>>> bucket = client.get_bucket('my-bucket')
>>> print(bucket.get_blob('/path/to/blob.txt'))
<Blob: my-bucket, /path/to/blob.txt>
>>> print(bucket.get_blob('/does-not-exist.txt'))
None
"""

def get_blob_snippet():
    from google.cloud import storage
    client = storage.Client()
    # Other setup?

    fake_mod = types.ModuleType('fake-mod')
    fake_mod.__doc__ = SNIPPET_GET_BLOB
    fake_globals = {'client': client}
    doctest.run_docstring_examples(fake_mod, fake_globals, verbose=False, name='get_blob')
Read more comments on GitHub >

github_iconTop Results From Across the Web

doctest — Test interactive Python examples — Python 3.11.1 ...
Source code: Lib/doctest.py The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to ......
Read more >
How to let pytest discover and run doctests in installed modules?
I found the answer to my own question. To quote pytest issue #2042: currently doctest-modules is fundamentally incompatible with testing ...
Read more >
How to run doctests — pytest documentation
By default, all files matching the test*.txt pattern will be run through the python standard doctest module. You can change the pattern by...
Read more >
How I'm testing in 2020 - James Bennett
So whenever I start a new project and get its tests in good shape, I turn on the coverage report for every test...
Read more >
Testing - Hugging Face
Once a PR is submitted it gets tested with 9 CircleCi jobs. ... the documentation examples are correct, you should check that the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found