-
-
Notifications
You must be signed in to change notification settings - Fork 682
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Ensure
rich_markup_mode=None
disables Rich formatting (#859)
- Loading branch information
Showing
4 changed files
with
64 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import typer | ||
import typer.completion | ||
from typer.testing import CliRunner | ||
|
||
runner = CliRunner() | ||
rounded = ["╭", "─", "┬", "╮", "│", "├", "┼", "┤", "╰", "┴", "╯"] | ||
|
||
|
||
def test_rich_markup_mode_none(): | ||
app = typer.Typer(rich_markup_mode=None) | ||
|
||
@app.command() | ||
def main(arg: str): | ||
"""Main function""" | ||
print(f"Hello {arg}") | ||
|
||
assert app.rich_markup_mode is None | ||
|
||
result = runner.invoke(app, ["World"]) | ||
assert "Hello World" in result.stdout | ||
|
||
result = runner.invoke(app, ["--help"]) | ||
assert all(c not in result.stdout for c in rounded) | ||
|
||
|
||
def test_rich_markup_mode_rich(): | ||
app = typer.Typer(rich_markup_mode="rich") | ||
|
||
@app.command() | ||
def main(arg: str): | ||
"""Main function""" | ||
print(f"Hello {arg}") | ||
|
||
assert app.rich_markup_mode == "rich" | ||
|
||
result = runner.invoke(app, ["World"]) | ||
assert "Hello World" in result.stdout | ||
|
||
result = runner.invoke(app, ["--help"]) | ||
assert any(c in result.stdout for c in rounded) |
This file contains 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
This file contains 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