Skip to content
Myr

Added new method itervalues() to LRUCache and deprecated itervalue()

Before adoption: this commit came in with the history the project adopted, so no landing records it.

(Fixes pallets/jinja#999)

authored by gokcegrbl · committed by gokcegrbl · parent 30685be · Browse files · 2 files+30 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+30 added−0 removed

  • tests:+21 added−0 removed
  • other:+9 added−0 removed

2 files+30 added−0 removed

modified:jinja2/utils.py+9 added
9 unmodified lines
10"""11import re12import json13import errno14import warnings15from collections import deque16from threading import Lock17from jinja2._compat import text_type, string_types, implements_iterator, \18 url_quote, abc
438 unmodified lines
457 return [x[1] for x in self.items()]458459 def itervalue(self):460 """Iterate over all values."""461 warnings.warn(DeprecationWarning(462 '"itervalue()" is deprecated and will be removed in version 2.12.'463 + ' Use "itervalues()" instead.'464 ), stacklevel=2)465 return self.itervalues()466467 def itervalues(self):468 """Iterate over all values."""469 return iter(self.values())470471 def keys(self):472 """Return a list of all keys ordered by most recent usage."""
179 unmodified lines
modified:tests/test_utils.py+21 added
30 unmodified lines
31 d["d"] = 432 assert len(d) == 333 assert 'a' in d and 'c' in d and 'd' in d and 'b' not in d3435 def test_itervalue_deprecated(self):36 cache = LRUCache(3)37 cache["a"] = 138 cache["b"] = 239 with pytest.deprecated_call():40 cache.itervalue()4142 def test_itervalues(self):43 cache = LRUCache(3)44 cache["b"] = 145 cache["a"] = 246 values = [v for v in cache.itervalues()]47 assert len(values) == 248 assert 1 in values49 assert 2 in values5051 def test_itervalues_empty(self):52 cache = LRUCache(2)53 values = [v for v in cache.itervalues()]54 assert len(values) == 05556 def test_pickleable(self):57 cache = LRUCache(2)58 cache["foo"] = 4259 cache["bar"] = 23
48 unmodified lines