diff options
author | Scott Moser <smoser@ubuntu.com> | 2014-07-23 12:56:39 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2014-07-23 12:56:39 -0400 |
commit | e921336a402423a702c74b757551bee10f3d771d (patch) | |
tree | 6d20c2cca580d99733173b2422cb2609f72a30b8 /tests/unittests/helpers.py | |
parent | e9f9c1e1cd47786b93491fd0f73467674c88828e (diff) | |
download | vyos-cloud-init-e921336a402423a702c74b757551bee10f3d771d.tar.gz vyos-cloud-init-e921336a402423a702c74b757551bee10f3d771d.zip |
fix httpretty based test cases if http_proxy is set.
previously this would fail:
http_proxy=http://foo.bar make test
now it will pass. This works around a bug where httpretty is not able to
patch http operations if http_proxy is set.
https://github.com/gabrielfalcao/HTTPretty/issues/122
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r-- | tests/unittests/helpers.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py index 970eb8cb..9700a4ca 100644 --- a/tests/unittests/helpers.py +++ b/tests/unittests/helpers.py @@ -233,6 +233,21 @@ class FilesystemMockingTestCase(ResourceUsingTestCase): self.patched_funcs.append((mod, f, func)) +class HttprettyTestCase(TestCase): + # necessary as http_proxy gets in the way of httpretty + # https://github.com/gabrielfalcao/HTTPretty/issues/122 + def setUp(self): + self.restore_proxy = os.environ.get('http_proxy') + if self.restore_proxy is not None: + del os.environ['http_proxy'] + super(HttprettyTestCase, self).setUp() + + def tearDown(self): + if self.restore_proxy: + os.environ['http_proxy'] = self.restore_proxy + super(HttprettyTestCase, self).tearDown() + + def populate_dir(path, files): if not os.path.exists(path): os.makedirs(path) |