mirror of https://github.com/docker/compose.git
utils: Fix typo in unique_everseen.
Signed-off-by: Antony MECHIN <antony.mechin@docker.com>
This commit is contained in:
parent
b64184e388
commit
eb86881af1
|
@ -176,6 +176,7 @@ def unique_everseen(iterable, key=lambda x: x):
|
|||
"List unique elements, preserving order. Remember all elements ever seen."
|
||||
seen = set()
|
||||
for element in iterable:
|
||||
if key(element) not in seen:
|
||||
seen.add(element)
|
||||
unique_key = key(element)
|
||||
if unique_key not in seen:
|
||||
seen.add(unique_key)
|
||||
yield element
|
||||
|
|
|
@ -72,5 +72,7 @@ class TestParseBytes(object):
|
|||
|
||||
class TestMoreItertools(object):
|
||||
def test_unique_everseen(self):
|
||||
assert list(utils.unique_everseen([2, 1, 2, 1])) == [2, 1]
|
||||
assert list(utils.unique_everseen([2, 1, 2, 1], hash)) == [2, 1]
|
||||
unique = utils.unique_everseen
|
||||
assert list(unique([2, 1, 2, 1])) == [2, 1]
|
||||
assert list(unique([2, 1, 2, 1], hash)) == [2, 1]
|
||||
assert list(unique([2, 1, 2, 1], lambda x: 'key_%s' % x)) == [2, 1]
|
||||
|
|
Loading…
Reference in New Issue