do not disable colorama in tests (#9187)

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.
This commit is contained in:
skshetry
2023-03-15 18:23:26 +05:45
committed by GitHub
parent 37ccc5e8d8
commit e6419b939d
+5 -2
View File
@@ -1,4 +1,4 @@
from contextlib import contextmanager
from contextlib import contextmanager, nullcontext
from typing import (
TYPE_CHECKING,
Any,
@@ -132,9 +132,12 @@ class Console:
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)