python/mach/mach/test/test_mach.py
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Fri, 27 May 2022 06:58:24 +0000
changeset 619020 ab65238291222763a2dd2f0ffc3c539d37a940f6
parent 554551 994ae8e4833c90447d91f0e26a718573cff5a514
permissions -rw-r--r--
no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD be -> 040b93d8fc0266fdc8696c86290152480570a8a8 eo -> 2aeb97991166e6e5d3514662ea7012744f724732 es-AR -> 3f2e985b37848b8d19ac9d01aa9ecd76895547bb it -> 12f68a74e363beee234126dcf25407f882d085ff

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from __future__ import absolute_import, unicode_literals

import os

from mozunit import main


def test_set_isatty_environ(monkeypatch, get_mach):
    # Make sure the 'MACH_STDOUT_ISATTY' variable gets set.
    monkeypatch.delenv("MACH_STDOUT_ISATTY", raising=False)
    monkeypatch.setattr(os, "isatty", lambda fd: True)

    m = get_mach()
    orig_run = m._run
    env_is_set = []

    def wrap_run(*args, **kwargs):
        env_is_set.append("MACH_STDOUT_ISATTY" in os.environ)
        return orig_run(*args, **kwargs)

    monkeypatch.setattr(m, "_run", wrap_run)

    ret = m.run([])
    assert ret == 0
    assert env_is_set[0]


if __name__ == "__main__":
    main()