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.

Use doctest to execute examples in the docstring

See original GitHub issue

📚 Documentation

Example snippets are inserted into the docstring to show usage. However, these pieces of code might be deprecated, or might not work. The module doctest aims to execute the tests written in docstring and it works fine with sphinx. It could help to detect earlier doc issues and provide a better doc.

Useful links

Note that some tests was written according to doctest https://github.com/pytorch/ignite/blob/b3d9849c2243be6068a64b5d1cf9c0ede727a2ea/ignite/handlers/timing.py#L30

The main point is the refactoring of every test to pass the validation. It means have consistent pieces of code (define training fn, engines, etc.) to provide reproducible examples.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sdesroziscommented, Jan 17, 2022

It’s done !

1reaction
vfdev-5commented, Jan 17, 2022

@sdesrozis can we close this issue as solved or still there is something to be done ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

doctest — Test interactive Python examples — Python 3.11.1 ...
This section examines in detail how doctest works: which docstrings it looks at, how it finds interactive examples, what execution context it uses,...
Read more >
Python's doctest: Document and Test Your Code at Once
The doctest module is able to run code that creates and imports objects, calls functions, assigns variables, evaluates expressions, and more.
Read more >
How To Write Doctests in Python - DigitalOcean
Our complete example code, including the add() function with a doctest, docstrings, and a call to invoke the doctest follows.
Read more >
doctest – Testing through documentation - PyMOTW
You can include instructions to run doctest against your source at the bottom of your modules. Use testmod() without any arguments to test...
Read more >
Testing in Python using doctest module - GeeksforGeeks
1. import testmod from doctest to test the function. 2. Define our test function. 3. Provide a suitable docstring containing desired output on ......
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