Exemplo n.º 1
0
def test_falsy():
    matrix = (
        (False, True),
        (True, False),
        ('false', True),  # i.e., is falsy
        ('', True),
        ('true', False),  # i.e, is not falsy
        ('123', False),
        (73, False),
    )
    for input, expected in matrix:
        actual = falsy(input)
        assert expected == actual

        # truthy is complement of falsy
        actual = truthy(input)
        assert expected != actual
Exemplo n.º 2
0
def get_travis_branch():
    """Get current branch per Travis environment variables

    If travis is building a PR, then TRAVIS_PULL_REQUEST is truthy and the
    name of the branch corresponding to the PR is stored in the
    TRAVIS_PULL_REQUEST_BRANCH environment variable. Else, the name of the
    branch is stored in the TRAVIS_BRANCH environment variable.

    See also:
        - <https://docs.travis-ci.com/user/environment-variables/#default-environment-variables>
    """  # noqa E501
    try:
        travis_pull_request = get_travis_env_or_fail('TRAVIS_PULL_REQUEST')
        if truthy(travis_pull_request):
            travis_pull_request_branch = get_travis_env_or_fail(
                'TRAVIS_PULL_REQUEST_BRANCH')
            return travis_pull_request_branch
        else:
            travis_branch = get_travis_env_or_fail('TRAVIS_BRANCH')
            return travis_branch
    except UnexpectedTravisEnvironmentError:
        return None
Exemplo n.º 3
0
def is_debug():
    return truthy(getenv('DEBUG', default='false'))
Exemplo n.º 4
0
 def _default_debug(self):
     _default = 'False'
     # fixme: truthy only works on strings as of ballet==0.6.11
     return truthy(getenv('ASSEMBLE_DEBUG', default=_default))