Skip to content

Commit 1086d83

Browse files
Enable soft wrapping for plain_print (#1288)
This helps avoid invalid output from `usethis show sonarqube`
1 parent b8e8cd6 commit 1086d83

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/usethis/_console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def plain_print(msg: str | Exception) -> None:
3232
or usethis_config.alert_only
3333
or usethis_config.instruct_only
3434
):
35-
console.print(msg)
35+
Console(force_terminal=False, soft_wrap=True).print(msg)
3636

3737

3838
def table_print(table: Table) -> None:

tests/usethis/test_console.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def test_out(self, capfd: pytest.CaptureFixture[str]) -> None:
2929
out, _ = capfd.readouterr()
3030
assert out == "Hello\n"
3131

32+
def test_no_line_wrapping(self, capfd: pytest.CaptureFixture[str]) -> None:
33+
# Arrange
34+
long_msg = "A" * 100
35+
36+
# Act
37+
plain_print(long_msg)
38+
39+
# Assert
40+
out, _ = capfd.readouterr()
41+
assert out == f"{long_msg}\n"
42+
3243

3344
class TestTablePrint:
3445
def test_out(self, capfd: pytest.CaptureFixture[str]) -> None:

0 commit comments

Comments
 (0)