mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 09:13:23 +00:00
Rewrite unnecessary list/tuple literals as set literals
This commit is contained in:
@@ -22,7 +22,7 @@ def assert_matcher(matcher_name):
|
|||||||
matcher = getattr(matchers, matcher_name)
|
matcher = getattr(matchers, matcher_name)
|
||||||
for k1, k2 in itertools.permutations(REQUESTS, 2):
|
for k1, k2 in itertools.permutations(REQUESTS, 2):
|
||||||
matched = matcher(REQUESTS[k1], REQUESTS[k2])
|
matched = matcher(REQUESTS[k1], REQUESTS[k2])
|
||||||
if matcher_name in set((k1, k2)):
|
if matcher_name in {k1, k2}:
|
||||||
assert not matched
|
assert not matched
|
||||||
else:
|
else:
|
||||||
assert matched
|
assert matched
|
||||||
@@ -31,7 +31,7 @@ def assert_matcher(matcher_name):
|
|||||||
def test_uri_matcher():
|
def test_uri_matcher():
|
||||||
for k1, k2 in itertools.permutations(REQUESTS, 2):
|
for k1, k2 in itertools.permutations(REQUESTS, 2):
|
||||||
matched = matchers.uri(REQUESTS[k1], REQUESTS[k2])
|
matched = matchers.uri(REQUESTS[k1], REQUESTS[k2])
|
||||||
if set((k1, k2)) != set(('base', 'method')):
|
if {k1, k2} != {'base', 'method'}:
|
||||||
assert not matched
|
assert not matched
|
||||||
else:
|
else:
|
||||||
assert matched
|
assert matched
|
||||||
|
|||||||
@@ -319,11 +319,11 @@ def test_additional_matchers():
|
|||||||
|
|
||||||
@vcr.use_cassette
|
@vcr.use_cassette
|
||||||
def function_defaults(cassette):
|
def function_defaults(cassette):
|
||||||
assert set(cassette._match_on) == set([vcr.matchers['uri']])
|
assert set(cassette._match_on) == {vcr.matchers['uri']}
|
||||||
|
|
||||||
@vcr.use_cassette(additional_matchers=('body',))
|
@vcr.use_cassette(additional_matchers=('body',))
|
||||||
def function_additional(cassette):
|
def function_additional(cassette):
|
||||||
assert set(cassette._match_on) == set([vcr.matchers['uri'], vcr.matchers['body']])
|
assert set(cassette._match_on) == {vcr.matchers['uri'], vcr.matchers['body']}
|
||||||
|
|
||||||
function_defaults()
|
function_defaults()
|
||||||
function_additional()
|
function_additional()
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ class VCRHTTPConnectionWithTimeout(VCRHTTPConnection,
|
|||||||
HTTPConnection.__init__.'''
|
HTTPConnection.__init__.'''
|
||||||
|
|
||||||
# Delete the keyword arguments that HTTPConnection would not recognize
|
# Delete the keyword arguments that HTTPConnection would not recognize
|
||||||
safe_keys = set(
|
safe_keys = {'host', 'port', 'strict', 'timeout', 'source_address'}
|
||||||
('host', 'port', 'strict', 'timeout', 'source_address')
|
|
||||||
)
|
|
||||||
unknown_keys = set(kwargs.keys()) - safe_keys
|
unknown_keys = set(kwargs.keys()) - safe_keys
|
||||||
safe_kwargs = kwargs.copy()
|
safe_kwargs = kwargs.copy()
|
||||||
for kw in unknown_keys:
|
for kw in unknown_keys:
|
||||||
@@ -33,7 +31,7 @@ class VCRHTTPSConnectionWithTimeout(VCRHTTPSConnection,
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|
||||||
# Delete the keyword arguments that HTTPSConnection would not recognize
|
# Delete the keyword arguments that HTTPSConnection would not recognize
|
||||||
safe_keys = set((
|
safe_keys = {
|
||||||
'host',
|
'host',
|
||||||
'port',
|
'port',
|
||||||
'key_file',
|
'key_file',
|
||||||
@@ -42,7 +40,7 @@ class VCRHTTPSConnectionWithTimeout(VCRHTTPSConnection,
|
|||||||
'timeout',
|
'timeout',
|
||||||
'source_address',
|
'source_address',
|
||||||
'ca_certs',
|
'ca_certs',
|
||||||
))
|
}
|
||||||
unknown_keys = set(kwargs.keys()) - safe_keys
|
unknown_keys = set(kwargs.keys()) - safe_keys
|
||||||
safe_kwargs = kwargs.copy()
|
safe_kwargs = kwargs.copy()
|
||||||
for kw in unknown_keys:
|
for kw in unknown_keys:
|
||||||
|
|||||||
Reference in New Issue
Block a user