with overridden_dns({'httpbin.org': '127.0.0.1'}):
cass_file = str(tmpdir.join('filter_qs.yaml'))
with vcr.use_cassette(cass_file, ignore_localhost=True) as cass:
- urlopen('http://localhost:{0}/'.format(httpbin.port))
+ urlopen('http://localhost:{}/'.format(httpbin.port))
assert len(cass) == 0
- urlopen('http://httpbin.org:{0}/'.format(httpbin.port))
+ urlopen('http://httpbin.org:{}/'.format(httpbin.port))
assert len(cass) == 1
cass_file,
ignore_hosts=['httpbin.org']
) as cass:
- urlopen('http://httpbin.org:{0}/'.format(httpbin.port))
+ urlopen('http://httpbin.org:{}/'.format(httpbin.port))
assert len(cass) == 0
- urlopen('http://localhost:{0}/'.format(httpbin.port))
+ urlopen('http://localhost:{}/'.format(httpbin.port))
assert len(cass) == 1
ignore_hosts=['httpbin.org'],
ignore_localhost=True
) as cass:
- urlopen('http://httpbin.org:{0}'.format(httpbin.port))
- urlopen('http://localhost:{0}'.format(httpbin.port))
+ urlopen('http://httpbin.org:{}'.format(httpbin.port))
+ urlopen('http://localhost:{}'.format(httpbin.port))
assert len(cass) == 0
with overridden_dns({'httpbin.org': '127.0.0.1'}):
cass_file = str(tmpdir.join('filter_qs.yaml'))
with vcr.use_cassette(cass_file, ignore_localhost=True) as cass:
- urlopen('http://localhost:{0}'.format(httpbin.port))
+ urlopen('http://localhost:{}'.format(httpbin.port))
assert len(cass) == 0
- urlopen('http://httpbin.org:{0}'.format(httpbin.port))
+ urlopen('http://httpbin.org:{}'.format(httpbin.port))
assert len(cass) == 1
with vcr.use_cassette(cass_file, ignore_localhost=True) as cass:
assert len(cass) == 1
- urlopen('http://localhost:{0}'.format(httpbin.port))
- urlopen('http://httpbin.org:{0}'.format(httpbin.port))
+ urlopen('http://localhost:{}'.format(httpbin.port))
+ urlopen('http://httpbin.org:{}'.format(httpbin.port))
assert len(cass) == 1
def test_auth(tmpdir, httpbin_both, verify_pool_mgr):
'''Ensure that we can handle basic auth'''
auth = ('user', 'passwd')
- headers = urllib3.util.make_headers(basic_auth='{0}:{1}'.format(*auth))
+ headers = urllib3.util.make_headers(basic_auth='{}:{}'.format(*auth))
url = httpbin_both.url + '/basic-auth/user/passwd'
with vcr.use_cassette(str(tmpdir.join('auth.yaml'))):
one = verify_pool_mgr.request('GET', url, headers=headers)
def test_auth_failed(tmpdir, httpbin_both, verify_pool_mgr):
'''Ensure that we can save failed auth statuses'''
auth = ('user', 'wrongwrongwrong')
- headers = urllib3.util.make_headers(basic_auth='{0}:{1}'.format(*auth))
+ headers = urllib3.util.make_headers(basic_auth='{}:{}'.format(*auth))
url = httpbin_both.url + '/basic-auth/user/passwd'
with vcr.use_cassette(str(tmpdir.join('auth-failed.yaml'))) as cass:
# Ensure that this is empty to begin with
pass
def __str__(self):
- return "<Cassette containing {0} recorded response(s)>".format(
+ return "<Cassette containing {} recorded response(s)>".format(
len(self)
)
serializer = self.serializers[serializer_name]
except KeyError:
raise KeyError(
- "Serializer {0} doesn't exist or isn't registered".format(
+ "Serializer {} doesn't exist or isn't registered".format(
serializer_name
)
)
matchers.append(self.matchers[m])
except KeyError:
raise KeyError(
- "Matcher {0} doesn't exist or isn't registered".format(m)
+ "Matcher {} doesn't exist or isn't registered".format(m)
)
return matchers
differences = [m for m in matches if not m[0]]
if differences:
log.debug(
- "Requests {0} and {1} differ according to "
- "the following matchers: {2}".format(r1, r2, differences)
+ "Requests {} and {} differ according to "
+ "the following matchers: {}".format(r1, r2, differences)
)
port = parts['port']
scheme = parts['protocol']
default_port = {'https': 443, 'http': 80}[scheme]
- parts['port'] = ':{0}'.format(port) if port != default_port else ''
+ parts['port'] = ':{}'.format(port) if port != default_port else ''
return "{protocol}://{host}{port}{path}".format(**parts)
for file_path in files:
migrated = try_migrate(file_path)
status = 'OK' if migrated else 'FAIL'
- sys.stderr.write("[{0}] {1}\n".format(status, file_path))
+ sys.stderr.write("[{}] {}\n".format(status, file_path))
sys.stderr.write("Done.\n")
bases = (base_class,)
if not issubclass(base_class, object): # Check for old style class
bases += (object,)
- return type('{0}{1}'.format(base_class.__name__, self._cassette._path),
+ return type('{}{}'.format(base_class.__name__, self._cassette._path),
bases, dict(cassette=self._cassette))
@_build_patchers_from_mock_triples_decorator
return self.scheme
def __str__(self):
- return "<Request ({0}) {1}>".format(self.method, self.uri)
+ return "<Request ({}) {}>".format(self.method, self.uri)
def __repr__(self):
return self.__str__()
"""
port = self.real_connection.port
default_port = {'https': 443, 'http': 80}[self._protocol]
- return ':{0}'.format(port) if port != default_port else ''
+ return ':{}'.format(port) if port != default_port else ''
def _uri(self, url):
"""Returns request absolute URI"""
- uri = "{0}://{1}{2}{3}".format(
+ uri = "{}://{}{}{}".format(
self._protocol,
self.real_connection.host,
self._port_postfix(),
def _url(self, uri):
"""Returns request selector url from absolute URI"""
- prefix = "{0}://{1}{2}".format(
+ prefix = "{}://{}{}".format(
self._protocol,
self.real_connection.host,
self._port_postfix(),
body=body,
headers=headers or {}
)
- log.debug('Got {0}'.format(self._vcr_request))
+ log.debug('Got {}'.format(self._vcr_request))
# Note: The request may not actually be finished at this point, so
# I'm not sending the actual request until getresponse(). This
body="",
headers={}
)
- log.debug('Got {0}'.format(self._vcr_request))
+ log.debug('Got {}'.format(self._vcr_request))
def putheader(self, header, *values):
self._vcr_request.headers[header] = values
# then return it
if self.cassette.can_play_response_for(self._vcr_request):
log.info(
- "Playing response for {0} from cassette".format(
+ "Playing response for {} from cassette".format(
self._vcr_request
)
)
# and return it.
log.info(
- "{0} not in cassette, sending to real server".format(
+ "{} not in cassette, sending to real server".format(
self._vcr_request
)
)