def fixed_environment_variables(): orig_environ = os.environ.copy() for var in dict(os.environ): if var not in ENV_WHITELIST: del os.environ[var] # disable casual interaction with python.org os.environ['PIP_INDEX_URL'] = '(total garbage)' os.environ[ 'PYTHONWARNINGS'] = 'ignore:Support for Python 3.0-3.2 has been dropped.:UserWarning' # normalize $PATH from sys import executable from os import defpath from os.path import dirname assert defpath.startswith(':') os.environ['PATH'] = dirname(executable) + defpath yield os.environ.clear() os.environ.update(orig_environ)
def fixed_environment_variables(): orig_environ = os.environ.copy() for var in dict(os.environ): if var not in ENV_WHITELIST: del os.environ[var] # disable casual interaction with python.org os.environ["PIP_INDEX_URL"] = "(total garbage)" # we can't ignore the python2.6 warning this way because $PYTHONWARNINGS was invented in python2.7 os.environ["PYTHONWARNINGS"] = "ignore:Support for Python 3.0-3.2 has been dropped.:UserWarning" # normalize $PATH from sys import executable from os import defpath from os.path import dirname assert defpath.startswith(":") os.environ["PATH"] = dirname(executable) + defpath yield os.environ.clear() os.environ.update(orig_environ)
def fixed_environment_variables(): orig_environ = os.environ.copy() for var in dict(os.environ): if var not in ENV_WHITELIST: del os.environ[var] # disable casual interaction with python.org os.environ['PIP_INDEX_URL'] = '(total garbage)' os.environ['PYTHONWARNINGS'] = 'ignore:Support for Python 3.0-3.2 has been dropped.:UserWarning' # Fixes argparse help tests. os.environ['COLUMNS'] = '1000' # normalize $PATH from sys import executable from os import defpath from os.path import dirname assert defpath.startswith(':') os.environ['PATH'] = dirname(executable) + defpath yield os.environ.clear() os.environ.update(orig_environ)