recent updates to `python3-colored` "break" the standalone tests
nega0 opened this issue · 2 comments
Recent updates to https://pypi.org/project/colored/ (dslackw/colored@0c83f9d6d and dslackw/colored@07b96ebc4) made colored
"tty aware". Now when redirecting stdout/stderr, colored
won't colorize unless FORCE_COLOR=1 is set in the environment. This applies to the (default) "standalone" tests.
Currently you get something like:
## update tests
$ CHEATSH_UPDATE_TESTS_RESULTS=YES bash tests/run-tests.sh
## this will 100% pass
$ bash tests/run-tests.sh
## this will have some test fails
$ CHEATSH_TEST_STANDALONE=NO bash tests/run-tests.sh
An example of a failing test is:
Running 17: az # chubin/cheat.sheets
curl -s http://localhost:8002/az
--- results/17^I2022-08-09 19:13:32.000000000 -0400
+++ /tmp/cht.sh.tests-BZChFgyKuYEhgr^I2022-08-09 19:14:23.000000000 -0400
@@ -1,4 +1,4 @@
- cheat.sheets:az
+^[[48;5;8m^[[24m cheat.sheets:az ^[[24m^[[0m
^[[38;5;248;03m# Microsoft Azure CLI 2.0^[[39;00m
^[[38;5;248;03m# Command-line tools for Azure^[[39;00m
@@ -95,7 +95,7 @@
^[[38;5;248;03m# detach disk^[[39;00m
^[[38;5;252maz^[[39m^[[38;5;252m ^[[39m^[[38;5;252mvm^[[39m^[[38;5;252m ^[[39m^[[38;5;252mdisk^[[39m^[[38;5;252m ^[[39m^[[38;5;252mdetach^[[39m^[[38;5;252m ^[[39m^[[38;5;252m--vm-name^[[39m^[[38;5;252m ^[[39m^[[38;5;252mvm1^[[39m^[[38;5;252m ^[[39m^[[38;5;252m-g^[[39m^[[38;5;252m ^[[39m^[[38;5;252mRESOURCE_GROUP^[[39m^[[38;5;252m ^[[39m^[[38;5;252m--name^[[39m^[[38;5;252m ^[[39m^[[38;5;252mDISK1_ID^[[39m
- tldr:az
+^[[48;5;8m^[[24m tldr:az ^[[24m^[[0m
^[[38;5;248;03m# az^[[39;00m
^[[38;5;248;03m# The official CLI tool for Microsoft Azure.^[[39;00m
^[[38;5;248;03m# Some subcommands such as `az login` have their own usage documentation.^[[39;00m
And a sample of the results file tests/results/17
, post-update:
diff --git a/tests/results/17 b/tests/results/17
index 6fb087f..802fded 100644
--- a/tests/results/17
+++ b/tests/results/17
@@ -1,37 +1,37 @@
-^[[48;5;8m^[[24m cheat.sheets:az ^[[24m^[[0m
-^[[38;5;246;03m# Microsoft Azure CLI 2.0^[[39;00m
-^[[38;5;246;03m# Command-line tools for Azure^[[39;00m
+ cheat.sheets:az
+^[[38;5;248;03m# Microsoft Azure CLI 2.0^[[39;00m
+^[[38;5;248;03m# Command-line tools for Azure^[[39;00m
You'll notice the section_name
"cheat.sheets:az" is no longer highlighted post-update. The following procedure worksforme. Note that the local server always provides colorized output, so FORCE_COLOR=1
does't do anything in that context.
## update tests
$ FORCE_COLOR=1 CHEATSH_UPDATE_TESTS_RESULTS=YES bash tests/run-tests.sh
## this will 100% pass
$ FORCE_COLOR=1 bash tests/run-tests.sh
## this will 100% pass
$ FORCE_COLOR=1 CHEATSH_TEST_STANDALONE=NO bash tests/run-tests.sh
## this will also 100% pass
$ CHEATSH_TEST_STANDALONE=NO bash tests/run-tests.sh
The best solutions is to either update tests/run-tests.sh
to always use FORCE_COLOR
or update the docs in tests/README.md
and tests/run-tests.sh
to this new discrepancy.
ugh. wrong venv.