Repository navigation
馃悰 Fix: Ensure rich formatting is preserved in printing tutorial tests - #1974
Closed
Vineshnayak wants to merge 1 commit into
Closed
Vineshnayak wants to merge 1 commit into
Vineshnayak wants to merge 1 commit into
Conversation
Contributor
|
This was marked as potentially AI generated and will be closed now. If this is an error, please provide additional details, make sure to read the docs about contributing and AI. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Discussion: N/A - Direct fix for failing tests on main branch
Description
This PR fixes two failing tests in the test suite:
tests/test_tutorial/test_printing/test_tutorial001.pyandtest_tutorial002.py.The Issue:
Currently, these tests fail in some environments because the
Consolemock strips ANSI escape codes whensys.stdoutis intercepted by theCliRunner. Whenrich.printdetects it is not writing to a standard TTY, it defaults the color system toNone, causing the normalized output assertions (which look for*placeholders) to fail.The Fix:
I have explicitly passed
color_system="standard"to the mockedConsoleinstances. This forcesrichto emit the expected formatting codes regardless of the test environment's stdout redirection.AI Disclaimer
Prompt:
AI transcript
The AI analyzed the Typer repository, executed the
pytestsuite, and identified that two tutorial printing tests were failing on themasterbranch due to theConsolemock losing formatting. The AI then updatedtest_tutorial001.pyandtest_tutorial002.pyto instantiate the mockedConsolewithcolor_system="standard", successfully restoring the formatting and allowing all tests to pass.Checklist