1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 01:03:24 +00:00

Merge pull request #100 from IvanMalison/immutable_keyword_defaults

Make defaults of Cassette constructor immutable. Clean up whitespace. Re...
This commit is contained in:
Kevin McCarthy
2014-09-12 14:01:55 -10:00
3 changed files with 8 additions and 9 deletions

View File

@@ -30,12 +30,12 @@ class Cassette(ContextDecorator):
path, path,
serializer=yamlserializer, serializer=yamlserializer,
record_mode='once', record_mode='once',
match_on=[uri, method], match_on=(uri, method),
filter_headers=[], filter_headers=(),
filter_query_parameters=[], filter_query_parameters=(),
before_record=None, before_record=None,
ignore_hosts=[], ignore_hosts=(),
ignore_localhost=[], ignore_localhost=()
): ):
self._path = path self._path = path
self._serializer = serializer self._serializer = serializer

View File

@@ -26,7 +26,7 @@ class Counter(dict):
>>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping >>> c = Counter({'a': 4, 'b': 2}) # a new counter from a mapping
>>> c = Counter(a=4, b=2) # a new counter from keyword args >>> c = Counter(a=4, b=2) # a new counter from keyword args
''' '''
self.update(iterable, **kwds) self.update(iterable, **kwds)
def __missing__(self, key): def __missing__(self, key):
@@ -39,7 +39,7 @@ class Counter(dict):
>>> Counter('abracadabra').most_common(3) >>> Counter('abracadabra').most_common(3)
[('a', 5), ('r', 2), ('b', 2)] [('a', 5), ('r', 2), ('b', 2)]
''' '''
if n is None: if n is None:
return sorted(self.iteritems(), key=itemgetter(1), reverse=True) return sorted(self.iteritems(), key=itemgetter(1), reverse=True)
return nlargest(n, self.iteritems(), key=itemgetter(1)) return nlargest(n, self.iteritems(), key=itemgetter(1))
@@ -78,7 +78,7 @@ class Counter(dict):
>>> c['h'] # four 'h' in which, witch, and watch >>> c['h'] # four 'h' in which, witch, and watch
4 4
''' '''
if iterable is not None: if iterable is not None:
if hasattr(iterable, 'iteritems'): if hasattr(iterable, 'iteritems'):
if self: if self:

View File

@@ -1,4 +1,3 @@
import tempfile
import os import os