Skip to content

🧪 Add tests for Output.success in console.py#10

Open
acathon wants to merge 1 commit intomainfrom
test-console-success-1766197546182321515
Open

🧪 Add tests for Output.success in console.py#10
acathon wants to merge 1 commit intomainfrom
test-console-success-1766197546182321515

Conversation

@acathon
Copy link
Copy Markdown
Owner

@acathon acathon commented Apr 25, 2026

🎯 What: Added missing tests for Output.success in src/fastman/console.py by creating a new tests/test_console.py file.
📊 Coverage: The new tests cover:

  • Successful rich output (when rich is installed/enabled).
  • Standard ANSI output fallback (when rich is absent).
  • The UnicodeEncodeError fallback branch in standard output to ensure non-unicode terminals are supported.
  • Proper logging verification across all code paths.
    Result: Enhanced the testing coverage and reliability of the Output class, ensuring terminal output behaves correctly under various environments.

PR created automatically by Jules for task 1766197546182321515 started by @acathon

Summary by CodeRabbit

Release Notes

  • Tests
    • Expanded test coverage for console output functionality.

Co-authored-by: acathon <8994370+acathon@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

📝 Walkthrough

Walkthrough

A new test suite for fastman.console.Output.success method is introduced, covering rich-enabled mode, rich-disabled mode with ANSI output verification, Unicode error handling with fallback printing, and custom configurations with icon=False and empty prefix parameters.

Changes

Cohort / File(s) Summary
Console Output Tests
tests/test_console.py
New test suite for Output.success method covering rich-enabled/disabled modes, ANSI styling verification, Unicode error fallback handling, logging assertions, and custom configuration scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 With whiskers twitched and tests galore,
Console success we now explore,
Rich and plain, both paths we trace,
Unicode falls but finds its place,
No error left without embrace! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title includes an emoji (🧪) and describes the main change: adding tests for Output.success in console.py, which aligns with the file additions and PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test-console-success-1766197546182321515

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/test_console.py`:
- Around line 36-44: Remove the stray developer comment inside the
test_success_without_rich_unicode_fallback test and delete the unused capsys
parameter from the test signature; the function should only take the mocked
fixtures (mock_print, mock_logger) since builtins.print is mocked and capsys is
not used—leave the assertions and calls to Output.success and mock_print intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 28a2b25f-f7bd-4389-bfe8-02b14291fdeb

📥 Commits

Reviewing files that changed from the base of the PR and between 6947287 and ac72d65.

📒 Files selected for processing (1)
  • tests/test_console.py

Comment thread tests/test_console.py
Comment on lines +36 to +44
def test_success_without_rich_unicode_fallback(self, mock_print, mock_logger, capsys):
# We patch print with a side_effect that raises UnicodeEncodeError on the first call,
# then succeeds on the second (fallback) call.
# But wait, capsys won't capture patched print if we do it this way easily, so let's verify mock_print calls.
Output.success("Unicode fallback message", icon=True, prefix="[PRE]")

# Verify fallback print logic
assert mock_print.call_count == 2
mock_print.assert_any_call(f"{Style.GREEN}[OK]{Style.RESET} [PRE] Unicode fallback message")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Clean up stray developer comment and remove unused capsys parameter.

Lines 37–39 read like an in-progress internal thought ("But wait, capsys won't capture patched print if we do it this way easily, so let's verify mock_print calls.") that should not land in the committed test. Additionally, capsys is declared on line 36 but never used — builtins.print is mocked, so the parameter is dead. Both should be removed for clarity.

🧹 Proposed cleanup
-    `@patch`("fastman.console.HAS_RICH", False)
-    `@patch`("fastman.console.logger.info")
-    `@patch`("builtins.print", side_effect=[UnicodeEncodeError("ascii", "", 0, 1, "mock"), None])
-    def test_success_without_rich_unicode_fallback(self, mock_print, mock_logger, capsys):
-        # We patch print with a side_effect that raises UnicodeEncodeError on the first call,
-        # then succeeds on the second (fallback) call.
-        # But wait, capsys won't capture patched print if we do it this way easily, so let's verify mock_print calls.
-        Output.success("Unicode fallback message", icon=True, prefix="[PRE]")
+    `@patch`("fastman.console.HAS_RICH", False)
+    `@patch`("fastman.console.logger.info")
+    `@patch`("builtins.print", side_effect=[UnicodeEncodeError("ascii", "", 0, 1, "mock"), None])
+    def test_success_without_rich_unicode_fallback(self, mock_print, mock_logger):
+        # First print() raises UnicodeEncodeError; the fallback branch should invoke print() a second time.
+        Output.success("Unicode fallback message", icon=True, prefix="[PRE]")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/test_console.py` around lines 36 - 44, Remove the stray developer
comment inside the test_success_without_rich_unicode_fallback test and delete
the unused capsys parameter from the test signature; the function should only
take the mocked fixtures (mock_print, mock_logger) since builtins.print is
mocked and capsys is not used—leave the assertions and calls to Output.success
and mock_print intact.

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.

1 participant