Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Run doctest with pytest#304

Closed
NickCao wants to merge 1 commit intomainfrom
context-manager-revamp-p2
Closed

Run doctest with pytest#304
NickCao wants to merge 1 commit intomainfrom
context-manager-revamp-p2

Conversation

@NickCao
Copy link
Copy Markdown
Collaborator

@NickCao NickCao commented Feb 20, 2025

Summary by CodeRabbit

  • Chores
    • Updated the process for running documentation tests with a more streamlined approach.
  • Documentation
    • Refined network adapter and driver examples with clearer naming and improved formatting.
    • Transitioned some examples to an interactive shell style for enhanced readability.
    • Removed extra setup and cleanup details to simplify the documentation for end-users.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 20, 2025

Walkthrough

The pull request modifies the documentation testing flow by updating the doctest target in the Makefile—from invoking a make-based command to executing pytest directly with options for markdown files. It also introduces new pytest fixtures in the adapters and drivers sections to set up testing environments, updates documentation examples to reference the new fixtures and imports, and adjusts formatting in several driver documentation files for clarity.

Changes

File(s) Change Summary
Makefile Modified the doctest target command from $(MAKE) -C docs doctest to a direct pytest call with --directory docs and --doctest-glob="*.md".
docs/source/api-reference/adapters/* Added a new conftest.py with pytest fixtures (network, adapters_namespace); updated network.md to modify import statements and example client references from client to network.
docs/source/api-reference/basedriver.md Converted the static code snippet block to an interactive Python shell format without changing functionality.
docs/source/api-reference/drivers/* Introduced a new conftest.py with pytest fixtures (pyserial, drivers_namespace); updated pyserial.md to use pyserial directly and removed setup/cleanup code; made cosmetic updates in sdwire.md, removed test setup from tftp.md, and inserted a blank line in ustreamer.md for readability.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant M as Makefile
    participant P as Pytest Runner
    participant A as Adapters Fixture
    participant D as Drivers Fixture

    U->>M: Run "doctest" target
    M->>P: Execute "uv run ... --directory docs pytest --doctest-glob=\"*.md\""
    P->>A: Load adapter tests (network, adapters_namespace)
    A-->>P: Provide network test context
    P->>D: Load driver tests (pyserial, drivers_namespace)
    D-->>P: Provide pyserial test context
Loading

Possibly related PRs

Suggested reviewers

  • mangelajo

Poem

In my burrow, I hop with glee,
New tests and fixtures set me free,
Makefile tuned to a sweeter beat,
Docs and drivers now complete.
Hopping through changes, oh what fun! 🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@NickCao NickCao force-pushed the context-manager-revamp-p2 branch from 8975072 to 490eb02 Compare February 24, 2025 16:36
@NickCao NickCao force-pushed the context-manager-revamp branch from 3c5b186 to 83d06fb Compare February 24, 2025 16:37
Base automatically changed from context-manager-revamp to main February 24, 2025 16:40
@NickCao NickCao force-pushed the context-manager-revamp-p2 branch from 490eb02 to 5cb620a Compare February 24, 2025 16:40
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 24, 2025

Deploy Preview for jumpstarter-docs failed. Why did it fail? →

Name Link
🔨 Latest commit 5cb620a
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/67bca116d4062e0008f26919

@NickCao NickCao marked this pull request as draft February 24, 2025 16:42
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
docs/source/api-reference/adapters/network.md (1)

97-101: Inconsistency in FabricAdapter Example
The FabricAdapter example still uses client=client.tcp_port instead of the updated network fixture seen in the other examples. For consistency and to avoid potential confusion, consider updating this example to use client=network.tcp_port—unless this is a deliberate choice to illustrate a different scenario.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ced480b and 5cb620a.

📒 Files selected for processing (9)
  • Makefile (1 hunks)
  • docs/source/api-reference/adapters/conftest.py (1 hunks)
  • docs/source/api-reference/adapters/network.md (1 hunks)
  • docs/source/api-reference/basedriver.md (1 hunks)
  • docs/source/api-reference/drivers/conftest.py (1 hunks)
  • docs/source/api-reference/drivers/pyserial.md (1 hunks)
  • docs/source/api-reference/drivers/sdwire.md (1 hunks)
  • docs/source/api-reference/drivers/tftp.md (0 hunks)
  • docs/source/api-reference/drivers/ustreamer.md (1 hunks)
💤 Files with no reviewable changes (1)
  • docs/source/api-reference/drivers/tftp.md
✅ Files skipped from review due to trivial changes (3)
  • docs/source/api-reference/drivers/sdwire.md
  • docs/source/api-reference/basedriver.md
  • docs/source/api-reference/drivers/ustreamer.md
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: e2e
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
🔇 Additional comments (10)
docs/source/api-reference/drivers/conftest.py (2)

7-10: LGTM! Well-structured fixture for testing serial communication.

The fixture correctly uses the loopback URL and serve utility for lifecycle management, providing a reliable way to test serial communication without actual hardware.


13-15: LGTM! Well-structured fixture for doctest namespace injection.

The fixture correctly uses autouse=True and injects the pyserial fixture into the doctest namespace, making it available for all doctests without explicit imports.

Makefile (1)

16-17: LGTM! Simplified doctest execution with direct pytest invocation.

The change streamlines the doctest execution by directly invoking pytest with appropriate options for markdown files.

docs/source/api-reference/adapters/conftest.py (2)

8-11: LGTM! Well-structured fixture for testing network communication.

The fixture correctly sets up a Composite instance with TCP and Unix socket EchoNetwork children, providing a comprehensive testing environment.


14-16: LGTM! Well-structured fixture for doctest namespace injection.

The fixture correctly uses autouse=True and injects the network fixture into the doctest namespace, making it available for all doctests without explicit imports.

docs/source/api-reference/drivers/pyserial.md (1)

34-39: LGTM! Well-structured examples demonstrating PySerial usage patterns.

The examples effectively demonstrate various usage patterns with the injected pyserial fixture, including:

  • Context manager usage with pexpect
  • Direct usage without context manager
  • Stream operations with and without context manager

Also applies to: 44-50, 55-58, 63-66

docs/source/api-reference/adapters/network.md (4)

42-52: Review TcpPortforwardAdapter Example: Consistent Fixture Usage
The updated example correctly imports TcpPortforwardAdapter and now uses client=network.tcp_port, aligning with the new pytest fixture. Please ensure that the network fixture is well documented and available in the testing scope so that users can readily adapt to this change.


58-67: Review UnixPortforwardAdapter and Mixed Adapter Example
The example now imports UnixPortforwardAdapter and uses client=network.unix_socket appropriately. Additionally, the subsequent demonstration using TcpPortforwardAdapter with a Unix domain socket (via network.unix_socket) effectively shows the flexibility in adapter handling.


74-77: Review NovncAdapter Example: Fixture Alignment
The updated NovncAdapter example now imports the correct module and uses client=network.tcp_port, making it consistent with other examples. This update clearly shows how to initialize the adapter with the network fixture.


85-90: Review PexpectAdapter Example: Updated Usage
The PexpectAdapter example now properly imports the adapter and utilizes client=network.tcp_port. The enhancements improve clarity and maintain consistency across the examples.

@mangelajo
Copy link
Copy Markdown
Member

Closing, thanks nick!

@mangelajo mangelajo closed this Jul 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants