Remove newest_slice and StatusBar._option.

newest_slice is no longer needed after the completion refactor. Now that
history is based on the SQL backend, LIMIT is used instead.

StatusBar._option is not used, though I'm not sure why vulture only caught it
now.
This commit is contained in:
Ryan Roden-Corrent 2017-02-19 21:39:15 -05:00
parent 1474e38eec
commit c6645d47ba
2 changed files with 0 additions and 50 deletions

View File

@ -737,25 +737,6 @@ def sanitize_filename(name, replacement='_'):
return name
def newest_slice(iterable, count):
"""Get an iterable for the n newest items of the given iterable.
Args:
count: How many elements to get.
0: get no items:
n: get the n newest items
-1: get all items
"""
if count < -1:
raise ValueError("count can't be smaller than -1!")
elif count == 0:
return []
elif count == -1 or len(iterable) < count:
return iterable
else:
return itertools.islice(iterable, len(iterable) - count, len(iterable))
def set_clipboard(data, selection=False):
"""Set the clipboard to some given data."""
if selection and not supports_selection():

View File

@ -759,37 +759,6 @@ def test_sanitize_filename_empty_replacement():
assert utils.sanitize_filename(name, replacement=None) == 'Bad File'
class TestNewestSlice:
"""Test newest_slice."""
def test_count_minus_two(self):
"""Test with a count of -2."""
with pytest.raises(ValueError):
utils.newest_slice([], -2)
@pytest.mark.parametrize('items, count, expected', [
# Count of -1 (all elements).
(range(20), -1, range(20)),
# Count of 0 (no elements).
(range(20), 0, []),
# Count which is much smaller than the iterable.
(range(20), 5, [15, 16, 17, 18, 19]),
# Count which is exactly one smaller."""
(range(5), 4, [1, 2, 3, 4]),
# Count which is just as large as the iterable."""
(range(5), 5, range(5)),
# Count which is one bigger than the iterable.
(range(5), 6, range(5)),
# Count which is much bigger than the iterable.
(range(5), 50, range(5)),
])
def test_good(self, items, count, expected):
"""Test slices which shouldn't raise an exception."""
sliced = utils.newest_slice(items, count)
assert list(sliced) == list(expected)
class TestGetSetClipboard:
@pytest.fixture(autouse=True)