GitHub user panlinux opened a pull request:
https://github.com/apache/libcloud/pull/1236
Unset the http_proxy environment variable before running tests.
## Unset the http_proxy environment variable before running tests.
### Description
Two connection tests (test_constructor and test_connection_to_unusual_port)
assume that there is no external real proxy in the test environment. Turns
out LibcloudConnection() will honor a http_proxy shell variable if it's set,
so if the test suite is run in such an environment, these tests will fail:
```
self = <libcloud.test.test_connection.BaseConnectionClassTestCase
testMethod=test_connection_to_unusual_port>
def test_connection_to_unusual_port(self):
conn = LibcloudConnection(host='localhost', port=8080)
> self.assertEqual(conn.proxy_scheme, None)
E AssertionError: 'http' != None
libcloud/test/test_connection.py:107: AssertionError
self = <libcloud.test.test_connection.BaseConnectionClassTestCase
testMethod=test_constructor>
def test_constructor(self):
conn = LibcloudConnection(host='localhost', port=80)
> self.assertEqual(conn.proxy_scheme, None)
E AssertionError: 'http' != None
libcloud/test/test_connection.py:80: AssertionError
```
I also added a test for this behavior (the honoring of `http_proxy`) to the
existing `test_constructor` test.
### Status
- done, ready for review
### Checklist (tick everything that applies)
- [ ] [Code
linting](http://libcloud.readthedocs.org/en/latest/development.html#code-style-guide)
(required, can be done after the PR checks)
- [ ] Documentation
- [x] [Tests](http://libcloud.readthedocs.org/en/latest/testing.html)
- [ ]
[ICLA](http://libcloud.readthedocs.org/en/latest/development.html#contributing-bigger-changes)
(required for bigger changes)
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/panlinux/libcloud
avoid-real-proxy-in-connection-tests
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/libcloud/pull/1236.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1236
----
commit 1fc07deba90c13ef651e1b7e57db6367f75d7522
Author: Andreas Hasenack <andreas@...>
Date: 2018-08-27T23:17:19Z
Unset the http_proxy environment variable before running tests.
Two connection tests (test_constructor and test_connection_to_unusual_port)
assume that there is no external real proxy in the test environment. Turns
out LibcloudConnection() will honor a http_proxy shell variable if it's set,
so if the test suite is run in such an environment, these tests will fail.
commit 56d1e829f8fe9add2df2f28e2d71ddfcbe6e32b0
Author: Andreas Hasenack <andreas@...>
Date: 2018-08-27T23:44:40Z
Update test_constructor() with a test for the http_proxy environment
variable.
----
---