Skip to content

Commit

Permalink
ConsoleRenderer: default to colorless when colorama is unavailable (#215
Browse files Browse the repository at this point in the history
)

'colorama' isn't a direct dependency of 'structlog', and as such it
might not be available. The console renderer should still work when it
isn't, though.
  • Loading branch information
danchr authored and hynek committed Aug 15, 2019
1 parent 0e209d9 commit 84da16a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/structlog/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class ConsoleRenderer(object):
def __init__(
self,
pad_event=_EVENT_WIDTH,
colors=True,
colors=_has_colorama,
force_colors=False,
repr_native_str=False,
level_styles=None,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_missing_colorama(self):
colorama is missing.
"""
with pytest.raises(SystemError) as e:
dev.ConsoleRenderer()
dev.ConsoleRenderer(colors=True)

assert (
"ConsoleRenderer with `colors=True` requires the colorama package "
Expand Down

0 comments on commit 84da16a

Please sign in to comment.