Skip to content

Commit

Permalink
src/molecule/console.py: Don't always set output wrapping
Browse files Browse the repository at this point in the history
The output soft wrapping with python enrich is enabled for all
terminals. This means that lines are wrapped to 80 when molecule
is run from tox or when a module ends importing this console module.
In the later case, this will wrap its output to 80 columns and
possibly break it, since the output won't be valid JSON as found in
ansible-community/molecule-vagrant#84.

As a possible solution, enable the soft wrapping on the same condition
as for the force_terminal terminal.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
  • Loading branch information
apatard committed Nov 23, 2020
1 parent 5852f34 commit 5902f78
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/molecule/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ def should_do_markup() -> bool:


console = Console(
force_terminal=should_do_markup(), theme=theme, record=True, redirect=True
force_terminal=should_do_markup(),
theme=theme,
record=True,
redirect=True,
soft_wrap=should_do_markup(),
)
# Define ANSIBLE_FORCE_COLOR if markup is enabled and another value is not
# already given. This assures that Ansible subprocesses are still colored,
Expand Down

0 comments on commit 5902f78

Please sign in to comment.