]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
Automatic formatters supported in Python 2.7+
authorHugo <hugovk@users.noreply.github.com>
Thu, 7 Dec 2017 11:32:08 +0000 (13:32 +0200)
committerHugo <hugovk@users.noreply.github.com>
Mon, 15 Jan 2018 07:54:11 +0000 (09:54 +0200)
tests/integration/test_ignore.py
tests/integration/test_urllib3.py
vcr/cassette.py
vcr/config.py
vcr/matchers.py
vcr/migration.py
vcr/patch.py
vcr/request.py
vcr/stubs/__init__.py

index 164edb8265726359d3e9b41fb4a56a5ac4957b88..9cfb5866a33f6ffc2f1b40af19ad08d709eb0d2f 100644 (file)
@@ -26,9 +26,9 @@ def test_ignore_localhost(tmpdir, httpbin):
     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
 
 
@@ -39,9 +39,9 @@ def test_ignore_httpbin(tmpdir, httpbin):
             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
 
 
@@ -53,8 +53,8 @@ def test_ignore_localhost_and_httpbin(tmpdir, httpbin):
             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
 
 
@@ -62,12 +62,12 @@ def test_ignore_localhost_twice(tmpdir, httpbin):
     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
index 51618c7f3f71a34343dfb0dfbc5971f99d4cd11e..d187f7b1983973f78413efc7600b1146db96e1a5 100644 (file)
@@ -56,7 +56,7 @@ def test_body(tmpdir, httpbin_both, verify_pool_mgr):
 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)
@@ -70,7 +70,7 @@ def test_auth(tmpdir, httpbin_both, verify_pool_mgr):
 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
index c6e3b81bf10cba09729e08f197c23abe7e8ada3a..4c958771080a03c158637aea78b27fe5757f7651 100644 (file)
@@ -304,7 +304,7 @@ class Cassette(object):
             pass
 
     def __str__(self):
-        return "<Cassette containing {0} recorded response(s)>".format(
+        return "<Cassette containing {} recorded response(s)>".format(
             len(self)
         )
 
index 91e031aa3d44ecba0afc8e841e09b7f36bafbfc0..48fb7feca0f157a95c7c7dc2d22914c21b73337b 100644 (file)
@@ -78,7 +78,7 @@ class VCR(object):
             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
                 )
             )
@@ -91,7 +91,7 @@ class VCR(object):
                 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
 
index 8fe334e49768a73572c4f24ff444400d8e316bef..f2029a87df957607649ea3e5e673028417d5dd44 100644 (file)
@@ -90,8 +90,8 @@ def _log_matches(r1, r2, matches):
     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)
         )
 
 
index 23b5e5eb442daa1a3e967ec484c0dcf95fc4ba05..ba5ae2c633efd1107d5e9935ab23ff5cef83b765 100644 (file)
@@ -59,7 +59,7 @@ def build_uri(**parts):
     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)
 
 
@@ -161,7 +161,7 @@ def main():
     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")
 
 
index 9de12a355fb2013533bbb7541ce208323ca679cd..ac8ef299ca7e56eb481a0ddaa66fc9d4a0f662ba 100644 (file)
@@ -169,7 +169,7 @@ class CassettePatcherBuilder(object):
         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
index 63e451e584c6202d154e630c1fe0e40e68ff915a..882db69782441e49b7e7278b0d77e7757977d309 100644 (file)
@@ -81,7 +81,7 @@ class Request(object):
         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__()
index 67cb5e7d7b57dc6b68ed337bc3247aa6d3ac7929..5ab819d7887e5c013037a3f5046f57035cddcf1c 100644 (file)
@@ -132,11 +132,11 @@ class VCRConnection(object):
         """
         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(),
@@ -146,7 +146,7 @@ class VCRConnection(object):
 
     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(),
@@ -161,7 +161,7 @@ class VCRConnection(object):
             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
@@ -180,7 +180,7 @@ class VCRConnection(object):
             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
@@ -214,7 +214,7 @@ class VCRConnection(object):
         # 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
                 )
             )
@@ -236,7 +236,7 @@ class VCRConnection(object):
             # 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
                 )
             )