Fixed #23107 -- use os.environ.setdefault to fix no-color and add tests