Add SafeCmd.run_sync with full parity tests - #10
Conversation
Provide run_sync() that mirrors async run() behaviour by driving the event loop internally via asyncio.run(). This ensures identical error and result semantics for synchronous contexts. - Add run_sync() method to SafeCmd class - Add unit tests for parity with async run() tests - Add BDD scenario for sync capture semantics - Document sync usage in users guide - Mark roadmap task as complete 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary by CodeRabbitRelease Notes
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughA new synchronous execution method Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (6)
🧰 Additional context used📓 Path-based instructions (11)docs/**/*.md📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.md📄 CodeRabbit inference engine (AGENTS.md)
Files:
⚙️ CodeRabbit configuration file
Files:
docs/**/*.{md,mdx,rst,txt}📄 CodeRabbit inference engine (docs/documentation-style-guide.md)
Files:
docs/**/*.{md,mdx,rst,txt,rs}📄 CodeRabbit inference engine (docs/documentation-style-guide.md)
Files:
docs/**/*.{md,mdx}📄 CodeRabbit inference engine (docs/documentation-style-guide.md)
Files:
**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
⚙️ CodeRabbit configuration file
Files:
**/unittests/test_*.py📄 CodeRabbit inference engine (.rules/python-00.md)
Files:
**/test_*.py📄 CodeRabbit inference engine (.rules/python-00.md)
Files:
**/*test*.py📄 CodeRabbit inference engine (.rules/python-exception-design-raising-handling-and-logging.md)
Files:
docs/users-guide.md📄 CodeRabbit inference engine (AGENTS.md)
Files:
docs/{users-guide.md,**/RELEASE*,**/CHANGELOG*}📄 CodeRabbit inference engine (docs/roadmap.md)
Files:
🧬 Code graph analysis (2)cuprum/unittests/test_safe_cmd_run.py (2)
tests/behaviour/test_execution_runtime.py (1)
🔍 Remote MCP RefSummary of Relevant Context for PR ReviewBased on my research, here are the key relevant facts for reviewing this pull request: asyncio.run() Design PatternThe implementation uses Architectural ConsiderationsThe PR implements
Testing Pattern NotesThe context indicates the test suite has identified and is addressing code duplication through parametrization (the suggested fixture-based approach with Coverage QualityThe test suite comprehensively covers both execution paths (async and sync) for:
🔇 Additional comments (11)
Comment |
|
@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix: cuprum/unittests/test_safe_cmd_run.py Comment on lines +442 to +461 def test_run_sync_decodes_with_configured_encoding(
python_builder: typ.Callable[..., SafeCmd],
) -> None:
"""run_sync() uses the configured encoding/errors when decoding output."""
command = python_builder(
"-c",
("import sys; sys.stdout.buffer.write(bytes([0x96])); sys.stdout.flush()"),
)
result = command.run_sync(
context=ExecutionContext(
encoding="cp1252",
errors="strict",
),
)
assert result.exit_code == 0
assert result.ok is True
assert result.stdout == "\u2013"
assert result.stderr == ""❌ New issue: Code Duplication |
This comment was marked as resolved.
This comment was marked as resolved.
…tion Replace 20 duplicate tests (10 pairs) with 10 parametrised tests using an execution_strategy fixture that runs both run() and run_sync() for each test case. This eliminates code duplication while maintaining identical test coverage. - Add execution_strategy fixture with params ["async", "sync"] - Consolidate test pairs into single parametrised tests - Update docstrings to reference "Both run() and run_sync()" - Keep async-only cancellation test separate - Reduce file from 461 to 329 lines (~29% reduction) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
Changes
Core Functionality
Tests
Documentation
Test Plan
🌿 Generated by Terry
ℹ️ Tag @terragon-labs to ask questions and address PR feedback
📎 Task: https://www.terragonlabs.com/task/9122a1b4-abf8-4c90-a8a1-c87d1e77cf7e