Skip to content

[CLIENT-4702] Convert docstring code examples to doctest format and validate them#1047

Draft
juliannguyen4 wants to merge 95 commits into
devfrom
CLIENT-4702-doc-validate-code-examples-using-doctest
Draft

[CLIENT-4702] Convert docstring code examples to doctest format and validate them#1047
juliannguyen4 wants to merge 95 commits into
devfrom
CLIENT-4702-doc-validate-code-examples-using-doctest

Conversation

@juliannguyen4
Copy link
Copy Markdown
Collaborator

@juliannguyen4 juliannguyen4 commented Apr 26, 2026

Extra Changes

  • Add ability to copy code examples while also stripping any characters that aren't valid Python syntax

Trade-offs

  • Code examples are harder to run because the Python REPL gives a syntax error when it encounters >>>. As a workaround, developers have to use IPython REPL with their specific desired version of Python to copy and run the code examples

Manual testing

https://aerospike-python-client--1047.org.readthedocs.build/en/1047/aerospike.html
https://aerospike-python-client--1047.org.readthedocs.build/en/1047/aerospike_helpers.batch.html
https://aerospike-python-client--1047.org.readthedocs.build/en/1047/aerospike_helpers.expressions.html

TODO

  • aerospike needs to be compiled before running doctest
  • Copying doctest formatted code into Python REPL causes syntax errors related to >>> Moved to a different format than doctest
  • Doctest teardown

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.44%. Comparing base (da9715f) to head (a758b7c).
⚠️ Report is 2 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1047   +/-   ##
=======================================
  Coverage   84.44%   84.44%           
=======================================
  Files          99       99           
  Lines       14062    14062           
=======================================
  Hits        11874    11874           
  Misses       2188     2188           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…the TLS test which needs to be run with a different job
…uple that contains the line number where it happened which isn't important
… run boilerplate code before each example in client.rst
…y code example. It doesn't seem possible with doctest + unittest
…plicate code block that shows the testblock code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants