Closed sebastic closed 7 years ago
The following patch may be sufficient, the test is skipped if the OFFLINE_TESTS environment variable is set:
--- a/tests/functional_tests.py
+++ b/tests/functional_tests.py
@@ -1,11 +1,16 @@
import httpretty
import unittest
import osmapi
+import os
+from nose.plugins.skip import SkipTest
class TestOsmApiFunctional(unittest.TestCase):
@httpretty.activate
def test_deleted_element_raises_exception(self):
+ if 'OFFLINE_TESTS' in os.environ:
+ raise SkipTest
+
httpretty.register_uri(
httpretty.GET,
"https://www.openstreetmap.org/api/0.6/relation/2911456/full",
@sebastic sorry about that, I'll look into it
Fixed in #79, now test_deleted_element_raises_exception
doesn't allow requests to unmocked URLs (they would cause an exception). I hope this solves your problem. The fix is released as v1.0.1.
Unfortunately the test still fails in 1.0.1:
======================================================================
ERROR: test_deleted_element_raises_exception (tests.functional_tests.TestOsmApiFunctional)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/httpretty/core.py", line 1146, in wrapper
return test(*args, **kw)
File "/build/python-osmapi-1.0.1/tests/functional_tests.py", line 17, in test_deleted_element_raises_exception
api.RelationFull(2911456)
File "/build/python-osmapi-1.0.1/osmapi/OsmApi.py", line 1159, in RelationFull
data = self._get(uri)
File "/build/python-osmapi-1.0.1/osmapi/OsmApi.py", line 2023, in _get
return self._http('GET', path, False, None)
File "/build/python-osmapi-1.0.1/osmapi/OsmApi.py", line 2003, in _http
"Give up after %s retries" % i
MaximumRetryLimitReachedError: Give up after 5 retries
-------------------- >> begin captured stdout << ---------------------
No mocking was registered, and real connections are not allowed (httpretty.allow_net_connect = False).
No mocking was registered, and real connections are not allowed (httpretty.allow_net_connect = False).
No mocking was registered, and real connections are not allowed (httpretty.allow_net_connect = False).
No mocking was registered, and real connections are not allowed (httpretty.allow_net_connect = False).
No mocking was registered, and real connections are not allowed (httpretty.allow_net_connect = False).
--------------------- >> end captured stdout << ----------------------
-------------------- >> begin captured logging << --------------------
urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): www.openstreetmap.org
urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): www.openstreetmap.org
urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): www.openstreetmap.org
urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): www.openstreetmap.org
urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): www.openstreetmap.org
--------------------- >> end captured logging << ---------------------
----------------------------------------------------------------------
Ran 81 tests in 15.261s
@sebastic Okay, I removed the new test and use the same mock as all the other tests. Should be fine with v1.0.2
Thanks, v1.0.2 builds successfully.
osmapi 1.0.0 fails to build due to test failures in build environments without network (like the Debian build chroots),
test_deleted_element_raises_exception
is not mocked unlike other tests: