def test_markup_detection_tty_no(mocker): mocker.patch("os.environ", {}) mocker.patch("sys.stdout.isatty", return_value=False) assert not logger.should_do_markup() mocker.resetall() mocker.stopall()
def test_markup_detection_tty_yes(mocker): mocker.patch("sys.stdout.isatty", return_value=True) mocker.patch("os.environ", {"TERM": "xterm"}) assert logger.should_do_markup() mocker.resetall() mocker.stopall()
def test_markup_detection_pycolors1(monkeypatch): monkeypatch.setenv("PY_COLORS", "1") assert logger.should_do_markup()
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. import os import click import click_completion import colorama import molecule from molecule import command from molecule.config import MOLECULE_DEBUG from molecule.logger import should_do_markup click_completion.init() colorama.init(autoreset=True, strip=not should_do_markup()) LOCAL_CONFIG = os.path.expanduser('~/.config/molecule/config.yml') ENV_FILE = '.env.yml' @click.group() @click.option('--debug/--no-debug', default=MOLECULE_DEBUG, help='Enable or disable debug mode. Default is disabled.') @click.option('--base-config', '-c', default=LOCAL_CONFIG, help=('Path to a base config. If provided Molecule will load ' "this config first, and deep merge each scenario's " 'molecule.yml on top. ({})').format(LOCAL_CONFIG))
def test_markup_detection_tty_yes(mocker): mocker.patch('sys.stdout.isatty', return_value=True) mocker.patch('os.environ', {'TERM': 'xterm'}) assert logger.should_do_markup() mocker.resetall() mocker.stopall()
def test_markup_detection_pycolors0(monkeypatch): monkeypatch.setenv('PY_COLORS', '0') assert not logger.should_do_markup()