Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Ensure rich_markup_mode=None disables Rich formatting #859

Merged
merged 6 commits into from
Aug 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/test_rich_markup_mode.py
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():
Copy link
Member Author

Choose a reason for hiding this comment

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

This test currently fails on master, which is clearly a bug IMO.

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():
Copy link

Choose a reason for hiding this comment

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

This test fails with 0.12.5 release

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)
E       assert False
E        +  where False = any(<generator object test_rich_markup_mode_rich.<locals>.<genexpr> at 0x7f931ae59d80>)

tests/test_rich_markup_mode.py:40: AssertionError

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @kraj, thanks for the comment. That's odd - I can't reproduce the test failure locally and the CI goes green with this change as well.

Could you please open a new discussion thread to look into this more, and provide us there with more information about your system setup and the failure you're seeing? 🙏

Copy link

Choose a reason for hiding this comment

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

I build a minimal image which just have a kernel+busybox+typer and its dependencies. So perhaps thats the difference, some implicit dependency coming in indirectly on full distributions like ubuntu, fedora etc in CI

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)