Skip to content

Commit

Permalink
do not disable colorama in tests (#9187)
Browse files Browse the repository at this point in the history
skip disabling colorama in tests

It might affect pytest as it wraps sys.stderr/sys.stdout for capsys fixture.
This is a temporary hack, as we might get rid of colorama soon.
  • Loading branch information
skshetry authored Mar 15, 2023
1 parent 37ccc5e commit e6419b9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dvc/ui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from contextlib import contextmanager
from contextlib import contextmanager, nullcontext
from typing import (
TYPE_CHECKING,
Any,
Expand Down Expand Up @@ -132,9 +132,12 @@ def write_json( # noqa: PLR0913
sort_keys=sort_keys,
)
if not highlight:
import os

# we don't need colorama to try to strip ansi codes
# when highlighting is disabled
with disable_colorama():
ctx = nullcontext() if "DVC_TEST" in os.environ else disable_colorama()
with ctx:
return self.write(json.text, stderr=stderr)
return self.rich_print(json, stderr=stderr, soft_wrap=True)

Expand Down

0 comments on commit e6419b9

Please sign in to comment.