145
145
version = version or Launchpad.DEFAULT_VERSION
146
146
cache = tempfile.mkdtemp(prefix='launchpadlib-cache-')
147
147
zope.testing.cleanup.addCleanUp(_clean_up_cache, (cache,))
148
return TestLaunchpad(credentials, None, None, service_root=service_root,
149
version=version, cache=cache)
152
class TestLaunchpad(Launchpad):
153
"""A variant of the Launchpad service root class providing test helpers.
156
def rawGet(self, url, follow_redirects=None):
157
"""Return a the result of a GET request for the given URL.
159
:param url: The URL of the request.
160
:param follow_redirects: If None, keep the default behaviour.
161
If True, follow redirect responses.
162
If False, do not follow a redirect response but return the
165
:return: The tuple (response, content)
167
default_redirect = self._browser._connection.follow_redirects
168
if follow_redirects is not None:
169
self._browser._connection.follow_redirects = follow_redirects
170
response, content = self._browser.get(url, return_response=True)
171
self._browser._connection.follow_redirects = default_redirect
172
return response, content
148
return Launchpad(credentials, None, None, service_root=service_root,
149
version=version, cache=cache)
175
152
class QueryCollector: