From e708c300aab336153d768c04a83fda9880fc3920 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 24 Jun 2015 16:18:45 -0400 Subject: [PATCH] tox: disable proxies when running nosetests httpretty does not handle proxy well, but the need for http_proxy and https_proxy is present if you're needing to install pip packages behind a proxy. Right now this will fail: http_proxy=http://my.proxy/ tox --recreate Example failures are in UrlHelperWaitForUrlsTest.test_url_wait_for it seems reasonable that we would never want proxy set when running tests as we should never be doing real http traffic. This just wraps our calls to nosetests with something that removes the http_proxy friends. Change-Id: I96585acaed0c8d70e1925b3859c85c87d1e07b2f --- tools/noproxy | 12 ++++++++++++ tox.ini | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 tools/noproxy diff --git a/tools/noproxy b/tools/noproxy new file mode 100644 index 00000000..d371e63c --- /dev/null +++ b/tools/noproxy @@ -0,0 +1,12 @@ +#!/usr/bin/env python +# +# clean http_proxy variables from environment as they make httpretty +# fail, but may be in the environment for reasons such as pip install +import os +import sys + +for k in ('http_proxy', 'https_proxy', 'HTTP_PROXY', 'HTTPS_PROXY'): + if k in os.environ: + del os.environ[k] + +os.execvpe(sys.argv[1], sys.argv[1:], os.environ) diff --git a/tox.ini b/tox.ini index 5d6e861f..9621c452 100644 --- a/tox.ini +++ b/tox.ini @@ -13,13 +13,13 @@ setenv = VIRTUAL_ENV={envdir} LC_ALL = en_US.utf-8 deps = -r{toxinidir}/test-requirements.txt -r{toxinidir}/requirements.txt -commands = nosetests {posargs} +commands = {envpython} {toxinidir}/tools/noproxy nosetests {posargs} [testenv:py27-coverage] -commands = nosetests --with-coverage --cover-erase --cover-package=cloudinit --cover-min-percentage=90 --cover-html {posargs} +commands = {envpython} {toxinidir}/tools/noproxy nosetests --with-coverage --cover-erase --cover-package=cloudinit --cover-min-percentage=90 --cover-html {posargs} [testenv:py34-coverage] -commands = nosetests --with-coverage --cover-erase --cover-package=cloudinit --cover-min-percentage=90 --cover-html {posargs} +commands = {envpython} {toxinidir}/tools/noproxy nosetests --with-coverage --cover-erase --cover-package=cloudinit --cover-min-percentage=90 --cover-html {posargs} [testenv:pep8] commands = flake8 {posargs}