def test_missing(self): with OsEnviron(dict()): var = get_os_env_bool('FOO') assert var is False, "var should be False, not %s" % repr(var) with OsEnviron({'FOO': '1'}): var = get_os_env_bool('BAR') assert var is False, "var should be False, not %s" % repr(var)
def test_false(self): for foo in [ 'FALSE', 'False', 'false', 'NO', 'No', 'no', 'N', 'n', 'OFF', 'Off', 'off', '0' ]: with OsEnviron({'FOO': foo}): var = get_os_env_bool('FOO', True) assert var is False, 'var should be True, not %s' % repr(var)
def test_true(self): for foo in [ 'TRUE', 'True', 'true', 'YES', 'Yes', 'yes', 'Y', 'y', 'ON', 'On', 'on', '1', '20', '-1' ]: with OsEnviron({'FOO': foo}): var = get_os_env_bool('FOO') assert var is True, 'var should be True, not %s' % repr(var)
def test_default(self): with OsEnviron({'FOO': 'other'}): var = get_os_env_bool('FOO', True) assert var is True, 'var should be True, not %s' % repr(var) var = get_os_env_bool('FOO', False) assert var is False, 'var should be False, not %s' % repr(var)