Ejemplo n.º 1
0
 def handle_proxy(self):
     if CONFIG.disable_proxy:
         with unset_env(
             ['http_proxy', 'https_proxy', 'HTTP_PROXY', ' HTTPS_PROXY']):
             yield
     else:
         yield
def test_watchdog_needs_envvar(envname):
    try:
        with env.unset_env([envname]):
            handler_watchdog(None, None)
    except AssertionError as err:
        assert 'envvar should be set' in str(err)
    else:
        raise RuntimeError('Had not raised an AssertionError')
Ejemplo n.º 3
0
def test_unset_env():
    try:
        os.environ[TEMP_NAME] = "junk_name"
        assert os.environ[TEMP_NAME] == "junk_name"

        with env.unset_env([TEMP_NAME]):
            with pytest.raises(KeyError):  # @UndefinedVariable
                os.environ[TEMP_NAME]

        assert os.environ[TEMP_NAME] == "junk_name"
    finally:
        if TEMP_NAME in os.environ:
            del os.environ[TEMP_NAME]
Ejemplo n.º 4
0
def test_unset_env():
    try:
        os.environ[TEMP_NAME] = 'junk_name'
        assert os.environ[TEMP_NAME] == 'junk_name'

        with env.unset_env([TEMP_NAME]):
            with pytest.raises(KeyError):  # @UndefinedVariable
                os.environ[TEMP_NAME]

        assert os.environ[TEMP_NAME] == 'junk_name'
    finally:
        if TEMP_NAME in os.environ:
            del os.environ[TEMP_NAME]
Ejemplo n.º 5
0
 def handle_proxy(self):
     if CONFIG.disable_proxy:
         with unset_env(['http_proxy', 'https_proxy', 'HTTP_PROXY', ' HTTPS_PROXY']):
             yield
     else:
         yield